LPC1768 DeepPowerDown recovery

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

LPC1768 DeepPowerDown recovery

1,110 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DavidKiryat8 on Wed Feb 10 02:34:45 MST 2016
My scenario is:
1) Enter DeepPowerDown mode
2) Wake every minute by way of the RTC
3) Check a GPIO pin and either go back to sleep or reset.

Using the PowerDown mode instead, this works.

I think that the GPIO pin may not be read correctly when woke up.
I read in one place in the user manual that GPIO is always enabled by I even re-enabled it in PCONP.

After DeepPowerDown mode, what steps must I perform in order to read a GPIO pin?

  // Turn Off PLL0 because of errata declared bug that leaves it on
  if (state.bPLL0_Running){
    pll_LPC_DisablePLL0();
    pll_LPC_DisablePLL1();
  }
  // Set CPU to use oscillator and not crystal
  pll_LPC_UseOscillator();
start_sleep:
  // Sleep
  CLKPWR_DeepPowerDown(); // no ram
  // Do we really need to wake up or can we just go back to sleep?
  LPC_SC->PCONP |= CLKPWR_PCONP_PCGPIO;
  if (!EXT_POWER_ON){
  goto start_sleep;
  }


Thanks

Labels (1)
0 Kudos
Reply
3 Replies

793 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DavidKiryat8 on Sun Feb 28 07:25:07 MST 2016
I wish NXP personnel would update the AN10915 pdf with more information.
There is very little information about the  Wake-up Interrupt Controller (WIC) in the newer user manual. I thought that the WIC was saving the program counter somewhere so it could process the next line after the __WFI(); when CLKPWR_DeepPowerDown() is called.
After continuously trying different code versions, I understood that the SRAM and internal registers must also be powered down to save power and the CPU is reset when the RTC interrupt occurs. Now my custom board's complete power is down to 0.73ma in DeepPowerDown mode as opposed to CLKPWR_PowerDown() mode's 3.41ma.
I would expect the difference between the two modes to be 30 to 40ua as shown in the chip's data sheet, so something in the LPC1768 is not shutting off in normal power down mode.
The pin directions, interrupts and PLL are all shutoff the same way.

Here is my code snippet for DeepPowerDown mode

In the main.c immediately:
#ifdef USE_LOW_POWER
#ifdef USE_DEEP_POWER_DOWN
  //---------------------------------------------------------------------------
  // Woke up from DeepPowerDown and still no External Power?
  //---------------------------------------------------------------------------
  if ((LPC_SC->PCON & BIT(11)) && !EXT_POWER_ON){
    //-------------------------------------------------------------------------
  // Set RTC to wakeup in 30s and go to the deepest sleep
  //-------------------------------------------------------------------------
  main_DeepPowerDownSleep();
  }else{
      //---------------------------------------------------------------------
      // PCON
      //  11 DPDFLAG Deep Power-down entry flag. Set when the Deep Power-down mode
      //    is successfully entered. Cleared by software writing a one to this bit.
      //---------------------------------------------------------------------
      LPC_SC->PCON |= BIT(11);
  }
#endif
#endif


inline void main_DeepPowerDownSleep(void)
{
  //---------------------------------------------------------------------------
  // Set CPU to run from RTC clock
  //---------------------------------------------------------------------------
  LPC_SC->CLKSRCSEL = 2;//RTC -> PLL0
  SystemCoreClock = FREQ_RTC_OSC / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
  //---------------------------------------------------------------------------
  // Just before sleeping Kick watchdog if used
  //---------------------------------------------------------------------------
#ifdef USE_WATCHDOG
  WDT_UpdateTimeOut(WDT_TIMEOUT_150S);
#endif
  RTC_Init(LPC_RTC);
  RTC_ResetClockTickCounter(LPC_RTC);
  RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, 0);
  //-------------------------------------------------------------------------
  // Set alarm time = 30s.
  // So, after each 30s, RTC will generate and wake-up system out of Deep PowerDown mode.
  //-------------------------------------------------------------------------
  RTC_SetAlarmTime (LPC_RTC, RTC_TIMETYPE_SECOND,30);
  RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, DISABLE);
  //-------------------------------------------------------------------------
  // Set the AMR for 5s match alarm interrupt
  //-------------------------------------------------------------------------
  RTC_AlarmIntConfig (LPC_RTC,RTC_TIMETYPE_SECOND, ENABLE);
  RTC_ClearIntPending(LPC_RTC,RTC_INT_COUNTER_INCREASE);
  RTC_ClearIntPending(LPC_RTC, RTC_INT_ALARM);
  RTC_Cmd(LPC_RTC, ENABLE);
  NVIC_EnableIRQ(RTC_IRQn);
  //-------------------------------------------------------------------------
  // PCON
  //  11 DPDFLAG Deep Power-down entry flag. Set when the Deep Power-down mode
  //    is successfully entered. Cleared by software writing a one to this bit.
  //-------------------------------------------------------------------------
  LPC_SC->PCON |= BIT(11);
  //-------------------------------------------------------------------------
  // Disable GPIO Power
  //-------------------------------------------------------------------------
  CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCGPIO,DISABLE);
  CLKPWR_DeepPowerDown(); // no ram
} // main_DeepPowerDownSleep


When I detect that external power has been off for so many seconds,
I change the CPU's pins directions , disable interrupts , change to the IRC turning off the Plls (errata pdf)  and then change to the RTC and call main_DeepPowerDownSleep.

If anyone has any idea why the normal power down mode takes so much current, please advise.

I have use cases where I need the SRAM to be powered so I would use normal power down mode.

Thanks






0 Kudos
Reply

793 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DavidKiryat8 on Thu Feb 18 06:34:51 MST 2016
To recap my scenario.
1) Put the LPC1768 into Deep power-down mode after a power outage.
2) Wake up every minute and check the external power pin.
3) If still no external power go back to sleep otherwise reset.

If I disable the RTC then the LPC1768 goes to sleep till reset as I would expect but I have no way to wake my board back up.
If I leave the RTC minute interrupt,  the board stays awake for a few seconds and then goes back to sleep every minute or so. The time awake is not logical.

I need more information of what state the CPU is when the RTC wakes it up.
1) How long does it take to wake up? I am using the IRC clock before going to sleep.
2) In order to read the GPIO pin P2.12 in the RTC interrupt what do I need to do?
3) What do I need to do before putting the LPC1768 back to sleep.
   Do I need to set the pin directions and pull ups, clock?

Could anyone test a code snippet and send me?

Thanks
 

0 Kudos
Reply

793 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DavidKiryat8 on Thu Feb 11 02:09:40 MST 2016
Does any one know what this line from the LPC1768 pdf (not user manual) means?
7.29.6.4 Deep power-down mode
The Deep power-down mode can only be entered from the RTC block. In Deep
power-down mode, power is shut off to the entire chip with the exception of the RTC
module and the RESET pin.
The LPC1768/66/65/64 can wake up from Deep power-down mode via the RESET pin or
an alarm match event of the RTC.


Does this mean that I must be using the PLL based on the RTC clock in order to enter Deep power-down mode?

I do not think that the RTC can be the source of the system clock without using the PLL.
Am I correct?

Does this mean the errata comment to disconnect the PLL should not be used?

  LPC_SC->PLL0CON &= ~(1<<1);  /* Disconnect the main PLL (PLL0) */
  LPC_SC->PLL0FEED = 0xAA;  /* Feed */
  LPC_SC->PLL0FEED = 0x55;  /* Feed */
  while ((LPC_SC->PLL0STAT & (1<<25)) != 0x00); /* Wait for main PLL (PLL0) to disconnect */
  LPC_SC->PLL0CON &= ~(1<<0);  /* Turn off the main PLL (PLL0) */
  LPC_SC->PLL0FEED = 0xAA;  /* Feed */
  LPC_SC->PLL0FEED = 0x55;  /* Feed */
  while ((LPC_SC->PLL0STAT & (1<<24)) != 0x00); /* Wait for main PLL (PLL0) to shut down */
  /************** Then enter into Deep sleep mode or Power-down mode*****************/


0 Kudos
Reply