From f149197aa8b755754edfd7717b73ba666498a0de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Tue, 3 Dec 2013 19:03:00 +0100 Subject: [PATCH] cc2538: lpm: Speed up the transition to the 32-MHz XOSC after wake-up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As recommended by the CC2538 User's Guide, set SYS_CTRL_CLOCK_CTRL.OSC_PD to 0 before asserting WFI, and set it to 1 after the system clock is sourced from the 32-MHz XOSC following wake-up. This allows to automatically start both oscillators upon wake-up in order to partially hide the 32-MHz XOSC startup time by the 16-MHz RCOSC startup time. Signed-off-by: Benoît Thébaudeau --- cpu/cc2538/lpm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpu/cc2538/lpm.c b/cpu/cc2538/lpm.c index da0349495..f1605771b 100644 --- a/cpu/cc2538/lpm.c +++ b/cpu/cc2538/lpm.c @@ -166,11 +166,20 @@ select_32_mhz_xosc(void) /* Wait for the switch to take place */ while((REG(SYS_CTRL_CLOCK_STA) & SYS_CTRL_CLOCK_STA_OSC) != 0); + + /* Power down the unused oscillator. */ + REG(SYS_CTRL_CLOCK_CTRL) |= SYS_CTRL_CLOCK_CTRL_OSC_PD; } /*---------------------------------------------------------------------------*/ static void select_16_mhz_rcosc(void) { + /* + * Power up both oscillators in order to speed up the transition to the 32-MHz + * XOSC after wake up. + */ + REG(SYS_CTRL_CLOCK_CTRL) &= ~SYS_CTRL_CLOCK_CTRL_OSC_PD; + /*First, make sure there is no ongoing clock source change */ while((REG(SYS_CTRL_CLOCK_STA) & SYS_CTRL_CLOCK_STA_SOURCE_CHANGE) != 0);