Content originally posted in LPCWare by wsyuen on Wed Dec 08 19:20:26 MST 2010
The datasheet of LPC13XX stated that the typical Deep Sleep mode current of LPC1343 is 30uA.
However, I tested on my target board is around 160uA.
Below is my Deep Sleep code which is modified from some example code. (changed from wakeup after 10sec to wakeup by certain IO)
Is there any improvement on my code which can reduce the Deep Sleep current?
Thank you very much.
// 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_USBPAD_PD |
SCB_PDSLEEPCFG_SYSPLL_PD |
SCB_PDSLEEPCFG_SYSOSC_PD |
SCB_PDSLEEPCFG_ADC_PD |
SCB_PDSLEEPCFG_BOD_PD |
SCB_PDSLEEPCFG_WDTOSC_PD;
// Enter deep sleep mode and wakeup after 10 seconds
pmuDeepSleep(pmuRegVal, 10);
void pmuDeepSleep(uint32_t sleepCtrl, uint32_t wakeupSeconds)
{
SCB_PDAWAKECFG = SCB_PDRUNCFG;
sleepCtrl |= (1 << 9) | (1 << 11);
SCB_PDSLEEPCFG = sleepCtrl;
SCB_SCR |= SCB_SCR_SLEEPDEEP; // after here, around 37ms
/* Configure system to run from WDT and set TMR32B0 for wakeup */
if (wakeupSeconds > 0)
{
/* Enable wakeup interrupts (any I/O pin can be used as a wakeup source) */
NVIC_EnableIRQ(WAKEUP4_IRQn); // P0.4
NVIC_EnableIRQ(WAKEUP5_IRQn); // P0.5
NVIC_EnableIRQ(WAKEUP6_IRQn); // P0.6
NVIC_EnableIRQ(WAKEUP7_IRQn); // P0.7
NVIC_EnableIRQ(WAKEUP12_IRQn); // P1.0
NVIC_EnableIRQ(WAKEUP14_IRQn); // P1.2
NVIC_EnableIRQ(WAKEUP36_IRQn); // P3.0
NVIC_EnableIRQ(WAKEUP37_IRQn); // P3.1
NVIC_EnableIRQ(WAKEUP38_IRQn); // P3.2
NVIC_EnableIRQ(WAKEUP39_IRQn); // P3.3 // after here, around 28ms
/* Use FALLING EDGE for wakeup detection. PIO3_0 - PIO3_3 */
SCB_STARTAPRP1 &= !(SCB_STARTAPRP1_APRPIO3_0|SCB_STARTAPRP1_APRPIO3_1|SCB_STARTAPRP1_APRPIO3_2|SCB_STARTAPRP1_APRPIO3_3);
/* Use FALLING EDGE for wakeup detection. PIO0_4 - PIO0_7, PIO1_0 & PIO1_2 */
SCB_STARTAPRP0 &= !(SCB_STARTAPRP0_APRPIO0_4|SCB_STARTAPRP0_APRPIO0_5|SCB_STARTAPRP0_APRPIO0_6|SCB_STARTAPRP0_APRPIO0_7|SCB_STARTAPRP0_APRPIO1_0);
SCB_STARTAPRP0 |= SCB_STARTAPRP0_APRPIO1_2; // Use RISING EDGE for wakeup detection
/* Clear all wakeup sources */
SCB_STARTRSRP0CLR = SCB_STARTRSRP0CLR_MASK;
/* Clear all wakeup sources */
SCB_STARTRSRP1CLR = SCB_STARTRSRP1CLR_MASK;
/* Enable PIO0_4 - PIO0_7, PIO1_0, PIO1_2 as wakeup source. */
SCB_STARTERP0 = (SCB_STARTERP0_ERPIO0_4|SCB_STARTERP0_ERPIO0_5|SCB_STARTERP0_ERPIO0_6|SCB_STARTERP0_ERPIO0_7|SCB_STARTERP0_ERPIO1_0|SCB_STARTERP0_ERPIO1_2);
/* Enable PIO3_0 - PIO3_3 as wakeup source. */
SCB_STARTERP1 = (SCB_STARTERP1_ERPIO3_0|SCB_STARTERP1_ERPIO3_1|SCB_STARTERP1_ERPIO3_2|SCB_STARTERP1_ERPIO3_3); // after here, around 34ms
}
__WFI();
return;
}