LPC11u68 - Can't Sleep after DeepSleep

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC11u68 - Can't Sleep after DeepSleep

Jump to solution
173 Views
AnyTimeTraveler
Contributor II

Hi,

Normal Sleep after DeepSleep also causes the LPC11u68 to go into DeepSleep.

 

First I invoke the following to initiate DeepSleep:

SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; // Set the DeepSleep-Bit
LPC_PMU->PCON = PMU_PCON_PM_DEEPSLEEP;
__WFI();

I wake up from it with the RTC Alarm Interrupt.

Then I call the following to go into normal Sleep:

// Unset the SLEEPDEEP Bit and enable all Interrupts to cause a Wakeup
SCB
->SCR = SCB_SCR_SEVONPEND_Msk;

LPC_PMU
->PCON = PMU_PCON_PM_SLEEP | PMU_PCON_SLEEPFLAG | PMU_PCON_NODPD;
__WFI();

From that, I want to wakeup with LPC_TIMER32_0, but the Interrupt doesn't happen.

 

I have replaced the sleep with a busy-loop and the Interrupt happened.

I have also tested the normal Sleep code before a DeepSleep and everything works as expected.

(See Section 5.2.1.1 in the LPC11u68 User Manual, Page 64)

 

Thank you for taking your time to look at this

Simon

Labels (1)
Tags (2)
0 Kudos
1 Solution
140 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

 

Recommend confirm the demo with RTC wakeup can work well as your requirement , then change it to  TIMER32_0. 

 

 

View solution in original post

0 Kudos
4 Replies
164 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello AnyTimeTraveler,

How about first test and refer to the PMU demo under lpcopen?

 

BR

Alice

 

0 Kudos
148 Views
AnyTimeTraveler
Contributor II

I just did.

This example uses the RTC instead of TIMER32_0 to wake from the sleep states.

So I added the initialisation for the timer like this:

Chip_TIMER_Init(LPC_TIMER32_0);
uint32_t timerFreq = Chip_Clock_GetSystemClockRate();
Chip_TIMER_Reset(LPC_TIMER32_0);
Chip_TIMER_PrescaleSet(LPC_TIMER32_0, timerFreq / 10);
Chip_TIMER_SetMatch(LPC_TIMER32_0, 1, 450);
Chip_TIMER_MatchEnableInt(LPC_TIMER32_0, 1);
Chip_TIMER_Enable(LPC_TIMER32_0);
NVIC_ClearPendingIRQ(TIMER_32_0_IRQn);
NVIC_EnableIRQ(TIMER_32_0_IRQn);

And altered the code to skip the DeepPowerDown, so that the chip won't get reset.

 

When Chip_PMU_SleepState was called the second time, a match-interrupt from the timer should have woken it up.

Instead, the timer did not continue ticking during sleep (which is should have done and did during the first sleep).

I printed the timer values out before and after each sleep.

 

See this gist for the code and the log from the MCU:

https://gist.github.com/AnyTimeTraveler/b1d98047a093a75329153b23939cbfc2

0 Kudos
141 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

 

Recommend confirm the demo with RTC wakeup can work well as your requirement , then change it to  TIMER32_0. 

 

 

View solution in original post

0 Kudos
98 Views
AnyTimeTraveler
Contributor II

The demo works for me, even after changing it to use the timer.

I don't see a difference between my code and the demo, but there must be one.

 

Thank you for pointing me in this direction.

0 Kudos