Content originally posted in LPCWare by Rob65 on Thu Jul 21 23:22:45 MST 2011
The user manual is your big friend (or foe ...)
Read as much as you can about the different power modes.
The differ a lot in the way in which different peripherals are powered and clocked:
Quote:
3.8.3.1 Power configuration in Deep-sleep mode[INDENT] Power consumption in Deep-sleep mode is determined by the Deep-sleep power configuration setting in the PDSLEEPCFG (Table 50) register:
• [COLOR=Red][B]The only clock source available in Deep-sleep mode is the watchdog oscillator.[/B][/COLOR] The watchdog oscillator can be left running in Deep-sleep mode if required for timer-controlled wake-up (see Section 3.9.3). [B][COLOR=Red]All other clock sources (the IRC and system oscillator) and the system PLL are shut down.[/COLOR][/B] The watchdog oscillator analog output frequency must be set to the lowest value of its analog cock output (bits FREQSEL in the WDTOSCCTRL = 0001, see Table 13).
• The BOD circuit can be left running in Deep-sleep mode if required by the application.
• If the watchdog oscillator is running in Deep-sleep mode, only the watchdog timer or one of the general-purpose timers should be enabled in SYSAHBCLKCTRL register to minimize power consumption.[/INDENT]
And knowing that the peripherals in the lpc13xx are (almost all) the same as the ones in the lpc11xx, you could have a look at the lpc11xx examples.
Yes I know ... it would have been so much nicer if NXP had a consistent set of examples for all the different chips :eek:
Check out the timedwakeup example in examples/NXP/LPC11xx/NXP_LPCXpresso1114-301_2011-01-27.zip in the LPCXpresso 4.0.5 release. That project contains an example of how to enter DeepSleep mode and wake up from it using TMR16B0.
You have to read the UM at least twice ... First start reading chapters 3 and 4 but don't try to understand everything at once, just read it and take notice of the global idea of the system. Then read the C-code in the example and check out the specific registers that are being used.
With a bit of luck you'll wake up from a zombie like reading mode (at least that's what happens to me most of the times :D) and your lpc13xx will sleep happily until woken by the alarm.
I have not looked at this in detail myself (yet) but as far as I can see TMR16B0 is programmed to set P0.8 on a match, the NVIC is programmed to generate an IRQ on P0.8, the timer is started, main clock changed to the watchdog oscillator and DeepSleep is entered.
After this the timer (running from the slow watch dog oscillator) will set P0.8 and this will trigger the IRQ handler.
This is also described in section 3.9 of the UM.
Apparently it is not possible to use the interrupt register of the timer since that does not trigger the start logic to enable some needed clocks (I think).
Regards,
Rob