LPC11u68 - Can't Sleep after DeepSleep

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

LPC11u68 - Can't Sleep after DeepSleep

跳至解决方案
3,049 次查看
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

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
3,016 次查看
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. 

 

 

在原帖中查看解决方案

0 项奖励
回复
4 回复数
3,040 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello AnyTimeTraveler,

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

 

BR

Alice

 

0 项奖励
回复
3,024 次查看
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 项奖励
回复
3,017 次查看
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. 

 

 

0 项奖励
回复
2,974 次查看
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 项奖励
回复