Waking up from Deep-Sleep on the LPC1114 and LPC1343

Posted by:  |  Monday, May 03, 2010

Go Back

There have been a number of questions on different forums about waking up from Deep-Sleep mode on the LPC1114 or LPC1343 lately, partially because the current user manual isn't very clear on this (for example, it's not terribly obvious whether a timer is able to run in deep-sleep mode or not).  After trying to wrap our head around this ourselves, we ended up contacting NXP directly, who were able to clear the matter up for us.  It is indeed possible to wakeup from deep-sleep in software using a timer, though it may not be exactly how you expected.

You enter deep-sleep mode by indicating which peripherals should be turned off, setting up the different registers controlling the sleep modes, and sending the WFI (Wait For Interrupt) command.  To exit deep-sleep mode, you simply need to change the state of a pre-configured wakeup pin (0.0..1.0 on the LPC1114 and 0.0..3.3 on the LPC1343), and your device will wakeup (entering the wakeup ISR).  That's relatively easy and the manual is clear on that ... what's a lot less clear is how you can wakeup from Deep-Sleep mode purely in SW (or if it's even possible).  It is indeed possible, but the only way to do so is with the following steps:

Configuring the LPC1114/LPC1343 to Wakeup from Deep-Sleep
  1. Before entering deep-sleep, switch the main clock source to WDTOSC (for the lowest possible power consumption)
  2. Next, find an available wakeup pin with a timer MAT (for example pin 0.1 on the LPC1114 and LPC1343 has CT32B0_MAT2)
  3. Set the matching timer delay to an appropriate length (for example, a 10s delay on CT32B0)
  4. Configure the timer's match control register to set the MAT pin (MAT2/0.1 in this case) high on match
  5. Enable the wakeup interrupt for the MAT pin, and enable the MAT pin as a wakeup source
  6. Start the timer
  7. Send the "WFI" command and enter Deep-Sleep mode

What this will do is allow the timer to continue running in deep-sleep using the WDTOSC as a clock source, and when a match occurs it will toggle the MAT pin from low to high, waking the device up.  At that point, you will enter the WAKEUP IRQ handler, and you can switch the main clock source back to the internal or external oscillator and adjust the clock accordingly.  (For reference sake, keeping a 32-bit timer running in deep-sleep with the WDTOSC at 10kHz consumes about 2uA more than if the device is put in deep-sleep mode with no SW wakeup enabled.)

If this isn't clear, we've added examples of entering and waking up from deep-sleep in both the LPC1114 and LPC1343 Code Base.  Both devices behave identically, aside from the smaller number of wakeup pins (13) on the LPC1114 and the difference peripherals that can be disabled in deep-sleep.  For an example, see pmuDeepSleep in pmu.c, or have a look at the latest source code on Google Code.

Using the above code, you can enter deep-sleep, and then wakeup after a fixed delay in seconds with the following commands (this assumes that you are using an LPC1343):

uint32_t pmuRegVal;

// Initialise power management
pmuInit();

// Inidicate which peripherals should be disabled in deep-sleep
pmuRegVal = SCB_PDSLEEPCFG_IRCOUT_PD | 
            SCB_PDSLEEPCFG_IRC_PD | 
            SCB_PDSLEEPCFG_FLASH_PD | 
            SCB_PDSLEEPCFG_USBPLL_PD | 
            SCB_PDSLEEPCFG_SYSPLL_PD | 
            SCB_PDSLEEPCFG_SYSOSC_PD | 
            SCB_PDSLEEPCFG_ADC_PD | 
            SCB_PDSLEEPCFG_BOD_PD;

// Enter deep sleep mode and wakeup after 5 seconds
pmuDeepSleep(pmuRegVal, 5);
  • Facebook
  • DZone It!
  • Digg It!
  • StumbleUpon
  • Technorati
  • Del.icio.us
  • NewsVine
  • Reddit
  • Blinklist
  • Furl it!

Comments  (3)

  • Colin D Bennett

    7/16/2010 12:00:00 AM

    Thanks for doing the research and posting this.

    This is what I have been wondering for a long time.  For most of the embedded system projects I've done, it has been a requirement to have a timed wake-up from deep sleep mode.

    Even though wake-up is possible, I believe NXP must do something huge to compete with ST's STM32L which has some fantastic low power features.  The LPC1100 and LPC1300 are definitely the price/performance leaders in the arena, but for wireless sensor networking and other battery powered applications the STM32L would be far and away the clear winner.

    The main problem with the LPC1100/LPC1300 deep-sleep wakeup using the watchdog oscillator and a timer/counter is the apparently terrible frequency accuracy of the watchdog oscillator.  (According to LPC13xx user manual section 5.8: “Any setting of the FREQSEL bits will yield a Fclkana value within ± 25% of the listed frequency value.”)

    A timing accuracy of ± 25% is OK for some applications that simply need periodic wakeups but the actual wakeup period is not critical, but for many applications it is important to keep a somewhat accurate running clock, for instance to maintain synchronization between nodes on a wireless network.

    Once again, thanks for posting this great info.  It will certainly enable many applications that otherwise would not be possible to implement with the LPC1100/LPC1300.

    Colin
  • Mike Stroven

    8/6/2010 12:00:00 AM

    This is great... Can you verify two things for me?
    1)  Does it matter which edge I use in the start logic (ie: my P0_1 pin is externally pulled up, can I use the falling edge to wake?)

    2)  In the AHBCLKCTRL register, are you enabling *only* the CT32B0? or do you need other bits enabled?

  • Kiona

    8/17/2011 12:00:00 AM

    Hey, good to find someone who ageres with me. GMTA.
Add a comment!
  1. Formatting options