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;
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;
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 220.127.116.11 in the LPC11u68 User Manual, Page 64)
Thank you for taking your time to look at this
Solved! Go to Solution.
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:
uint32_t timerFreq = Chip_Clock_GetSystemClockRate();
Chip_TIMER_PrescaleSet(LPC_TIMER32_0, timerFreq / 10);
Chip_TIMER_SetMatch(LPC_TIMER32_0, 1, 450);
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:
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.