Deep Sleep Current in LPC1343

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Deep Sleep Current in LPC1343

3,582 Views
lpcware
NXP Employee
NXP Employee
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;
}
0 Kudos
Reply
17 Replies

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by vspuri on Tue Aug 30 00:34:24 MST 2011
Is there any way to wake up the LPC13xx from deep sleep using timer. I know this can be done by clocking the timer in deepsleep mode using WD Oscillator. But the WD oscillator has 40% variance. I can tolerate 5% accuracy. Is there any way to enable IRC in deep sleep, and clock the timer with IRC
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Tue Mar 01 03:00:52 MST 2011
Lowering the power consumption of any board is a highly iterative process. I've been working on a few wireless boards, and it took a number of optimisations and adjustments in both HW and SW to get the power consumption to a low enough level (25uA in deep sleep with a SW timer running for wakeup).

Some of the things to look out for are:

[LIST]
[*]Make sure any ADC pins are initialised and configured as ADC or you will waste power, or set the ADC pins to an appropriate state before entering deep sleep.
[*]Make sure all internal resistors are set to an appropriate state especially if they are connected to something (a transistor, etc.).
[*]If you have any SPI devices, and you haven't made a provision for this in HW, you might want to try switching to SPI/SSP pins to GPIO output and GND before going into deep sleep. I noticed when I had a micro-SD card inserted it was drawing 500-700uA because of the SPI lines, even though the power was shut off to the card via a FET/transistor combination.
[*]Try to avoid any unecessary external pullup resistors as much as possible.
[*]Make sure any external devices (I2C sensors, etc.) are in sleep mode, or if they only use a couple mA, try powering them from a GPIO pin and shutting them off completely that way by putting the pin low.
[*]Use a 'dual-output' voltage regulator like the TPS780, which allows you to select between 3.3V and 2.2V output by toggling the select pin. They come in the same standard SOT23-5 package, but this allows you to switch to 2.2V in deep sleep, and then back to 3.3V on wakeup. Since the 1114 can run down to 1.8V (though it behaves differently below 2.0V off the top of my head), you can also run the board in active mode at 2.2V, and only switch to 3.3V when you really need it such as writing to a micro-SD card (since these are 3.3V only) or a 3.3V sensor.
[/LIST]If you want a basic circuit to be able to turn an external device off (>4mA meaning you can't use a GPIO pin) with no meaningful power loss, you might want to look at the following. I'm using this to disable both the SD card and a voltage divider I have to measure the battery voltage (since it would be constantly drawing current if it wasn't disabled when not in use). See "Controllable Voltage Divider": http://www.microbuilder.eu/Tutorials/Fundamentals/MeasuringBatteryVoltage.aspx

There's no magic formula to getting the lowest possible power consumption on your board, it's just a lot of little steps and attention to detail.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Tue Jan 18 11:54:38 MST 2011
Maybe your part has been damaged. Can you try a different sample of MCU?
Is the Brownout Detect disabled in your software?
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Mon Jan 17 21:57:43 MST 2011
Any suggestions?
Thank you very much.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Fri Jan 14 03:38:46 MST 2011
I tried several testings but still cannot reduce the Deep Sleep current.
How I can set the settings in Deep Sleep mode so that the MCU can achieve a nearly 30uA consumption?
Is there any sample code?
Please help. Thank you very much.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Thu Jan 13 17:47:47 MST 2011

Quote: Zero
So you have to fight with Deep Sleep.



RF has a reputation for being difficult, but my own experience has been that developping low-power devices (as in years on battery power) is far more challenging.  Those last uA can be really tough to isolate.

I'm up to 12 revisions on a small battery+solar powered wireless sensor node ... the RF was fine from the first board ... it's been figuring out how to get the deep sleep current as low as possible that took the other 11. :-)
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jan 13 05:19:21 MST 2011
User manual:

Quote:

3.8.4 Deep power-down mode
In Deep power-down mode, power and clocks are shut off to the entire chip with the exception of the WAKEUP pin.
...
All functional pins are tri-stated in Deep power-down mode except for the WAKEUP pin.



So you have to fight with Deep Sleep.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Thu Jan 13 02:54:27 MST 2011
Thanks, I tried the method but it seems that it cannot apply to my case.

The keys are arranged in a key matrix such that column and row are connected to I/Os. So that the key scanning is by shorting one IO to another IO.

However, in Deep Power Down mode, it seems that all IOs will be power off and no function.
So, the key cannot wakeup the MCU.

Is there any method can only enable IO in Deep Power Down mode?
If not, is there any setting in Deep Sleep mode can achieve a 30uA current consumption?
Thank you very much.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jan 13 00:45:18 MST 2011

Quote: wsyuen
As I have to wakeup by many keys (allocated in several I/Os), can I use Power Down mode? (as Power Down mode only can wakeup by a single I/O)



Yes !!!!

Just connect (serial) your keys with a diode to the wakeup pin :)
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Thu Jan 13 00:35:46 MST 2011
As I have to wakeup by many keys (allocated in several I/Os), can I use Power Down mode? (as Power Down mode only can wakeup by a single I/O)
If not, I need to use Deep Sleep mode.

I tested my board if it runs into Power Down mode, it consume 20uA. That means other components on my board will not use over 20uA.

According to the spec of LPC1343, the typical Deep Sleep mode current is 30uA.
And, if my board will consume 20uA, the overall current should be around 50uA.
However, now if it runs into Deep Sleep mode, the board is consuming 230uA.

How I can set the settings in Deep Sleep mode so that the MCU can achieve a nearly 30uA consumption?
Is there any sample code?
Thanks.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Wed Jan 12 23:25:19 MST 2011

Quote: Zero

Read LPC1343 Code Base Documentation of

http://www.microbuilder.eu/projects/LPC1343ReferenceDesign/CodeBaseDocumentation.aspx



Ouch ... I need to update that page.  It's been almost a year. :p

If all you want to do is wakeup on a button press, that's exactly what deep power down mode is intended for and it's the easiest mode to use.  The only thing to keep in mind is that you have to use the 'WAKEUP' pin to wake the device up (P1.4 on the 1343/1114).  Hook a button up to P1.4, enter deep power down mode (there's an example in 'pmu' of all the NXP demo software, or just run 'pmuPowerDown' if you're using the SW off microbulder.eu), and when the 1343 detects a low level on P1.4 it will wakeup from deep power down and enter 'WAKEUP_IRQHandler' where you can reconfigure the system.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Jan 12 21:06:01 MST 2011
Like Deep power-down ?

http://www.lmgtfy.com/?q= LPC1343 "power down" example

Read LPC1343 Code Base Documentation of

http://www.microbuilder.eu/projects/LPC1343ReferenceDesign/CodeBaseDocumentation.aspx
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Wed Jan 12 20:25:58 MST 2011
Because I do not need the MCU to wakeup after a defined time, I'm not intend to use Watchdog timer in the Deep Sleep mode.
Instead, I want the MCU to be wakeup be I/O port (e.g. press a key)

How I can set the Clock in Deep Sleep mode so that the MCU can achieve a nearly 30uA consumption?
Please help.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Fri Dec 10 10:21:52 MST 2010
Looks like you are setting up the WDO and timer to run during deep sleep instead of using the internal 12 MHz RC oscillator which shuts down in deep sleep.

I did not see the code where you set up the WDO divisor so I don't know how you've set it up, but given that you are leaving a clock running in Deep Sleep mode, for the lowest current, it is important to run at the lowest possible speed with the maximum divider.

To speed up entering and exiting deep sleep mode with a slow clock (could be as slow as 9 kHz) all of your other code (for example you are enabling all of the GPIO interrupts) should run at normal speed or simply run once at startup and the low-speed clock should only be enabled just before __WFI. After wake up, in your interrupt, the first thing the code does should be to switch back to the normal clock (IRC or crystal or PLL, etc.) Here is an example (this is for the LPC1114 but should be similar for the LPC1343):
void EnterDeepSleep(void)
{
    LPC_TMR16B0->EMR = BF_TIMER_EMR_SETOUT0; // set timer to drive P0_8 high at match

#ifndef DEBUG
    // Shut down clocks to almost everything
    LPC_SYSCON->SYSAHBCLKCTRL = BF_SYSAHBCLKCTRL_SLEEP;

    SCB->SCR |= BF_SCR_SLEEPDEEP; // Set SLEEPDEEP bit so MCU will enter DeepSleep mode on __WFI();

    // Switch main clock to low-speed WDO
    LPC_SYSCON->MAINCLKSEL = MAINCLKSEL_SEL_WDOSC;
    LPC_SYSCON->MAINCLKUEN = 0;
    LPC_SYSCON->MAINCLKUEN = 1; // toggle to enable
    LPC_SYSCON->MAINCLKUEN = 0;
#endif

    // Preload clock selection for quick switch back to IRC on wakeup
    LPC_SYSCON->MAINCLKSEL = MAINCLKSEL_SEL_IRCOSC;

    LPC_TMR16B0->TCR = BF_TIMER_TCR_RUN; // start sleep timer

    __WFI();                            // Enter deep sleep mode
}

void WAKEUP_IRQHandler(void)
{
    LPC_SYSCON->MAINCLKUEN = 1;         // Restore main clock to IRC 12 MHz

    LPC_TMR16B0->EMR = 0;// Clear match bit on timer

    LPC_SYSCON->STARTRSRP0CLR       =   BF_STARTLOGIC_P0_8; // Clear pending bit on start logic

    SCB->SCR &= ~BF_SCR_SLEEPDEEP; // Clear SLEEPDEEP bit so MCU will enter Sleep mode on __WFI();


    // Restore clocks to chip modules
    LPC_SYSCON->SYSAHBCLKCTRL = BF_SYSAHBCLKCTRL_RUN;
}

One last tip- you are using the WDO self-wakeup but the WDO has a broad frequency tolerance. To work around this, it is possible to use a timer running from the IRC or crystal to measure the WDT count speed and then adjust your WDO wakeup time.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Thu Dec 09 01:58:02 MST 2010
Coming out of reset, every(?) GPIO pin on the 13xx/11xx will have it's internal pullup enabled ... you probably want to disable all the pullup resistors and set the pins as output and to GND except the pins you use for something specific.

You may also want to have a look at AN10973 on the low-power modes for the 131x and 134x.  Pages 11-13 have some useful tips on this:

http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC1343
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Thu Dec 09 01:14:54 MST 2010
The 160uA is for the whole board.
However, I checked other parts and they will not occupy 130uA so much.
So, I want to know whether my Deep Sleep code is as good as possible.
Most of the IOs are set as output "low" or input with external pull-high resistors.
0 Kudos
Reply

3,491 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Wed Dec 08 20:02:44 MST 2010
That 30uA figure is for the MCU only, and not everything else on your boards like the voltage regulator (if there is one) and any other components ... is that 160uA only for your MCU or for your entire board?

Any power savings that you can make are probably elsewhere in the code like the way that you configure your GPIO pins (they default to having the internal pullup resistors enabled, for example).  How are you setting your unused GPIO pins either on startup or before entering deep-sleep?
0 Kudos
Reply