Hello all,
I'm working on a project using the LCPXpresso LPC11C24 Board Rev B with LPC-Link and I need to implement Deep Sleep mode for low power consumption usage. I'm also using MCUXpresso 10.2.1.
I followed the CMSIS example code regarding the PMU and I've a bit adapted it to my setup (it wakes up with pin 0.2), and apparently the chip CAN go to Deep Sleep (I stressed the "can" because I'm not entirely sure, as there's no debug option available) but when it wakes up it gets stuck in IntDefaultHandler().
I followed the example code and the WAKEUP_IRQ handler as explained, but there must be something I missed.
Here's the code:
void setup_sleep_state()
{
LPC_SYSCTL->SYSAHBCLKCTRL |= (1<<6);
LPC_SYSCTL->STARTAPRP0 = 0x00000000; //SET FALLING EDGE on INTR pins
LPC_SYSCTL->STARTRSRP0CLR = 0x344;
LPC_SYSCTL->STARTERP0 = 0x344;
LPC_SYSCTL->STARTSRP0 = 0x344;
LPC_PMU->PCON = 0x00000000;
LPC_SYSCTL->PDRUNCFG &= ~ ((1<<0) | (1<<1) | (1<<2));
LPC_SYSCTL->MAINCLKSEL = 0x0;
LPC_SYSCTL->MAINCLKUEN = 0x0;
LPC_SYSCTL->MAINCLKUEN = 0x1;
while (!(LPC_SYSCTL->MAINCLKUEN & 0x01));
LPC_SYSCTL->PDSLEEPCFG = 0x000018F7; //WDT off, BOD off
LPC_SYSCTL->PDWAKECFG = LPC_SYSCTL->PDRUNCFG;
NVIC_ClearPendingIRQ(PIO0_2_IRQn);
NVIC_EnableIRQ(PIO0_2_IRQn);
return;
}
void enter_sleep_state()
{
//DEEP SLEEP mode
SCB->SCR |= 0x04;
__WFI();
}
void WAKEUP_IRQHandler(void)
{
uint32_t reg;
reg = LPC_SYSCTL->STARTSRP0;
if (reg != 0) LPC_SYSCTL->STARTRSRP0CLR = reg;
__NOP();
return;
}
When it enters Deep Sleep mode, the debugger on MCUXpresso says (as expected) that there's no connection to the target, and this happens until I connect pin 0.2 to GND (as interrupt is on falling edge).
When I then suspend the code execution, it gets stuck in the line right after __WFI() and it says <signal handler called>() at 0xfffffff9.
Any suggestion or help will be really appreciated.
Thank you in advance!
Hi Federico Fiorini ,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
After reviewing the code and your statement, I consider the LPC11C24 can enter the deep sleep mode, about the question, I was a bit confused, how you find the chip will be stuck in the IntDefaultHandler after chip wake up, as IDE will lost the connection after the MCU enter the low power mode, in another word, it's impossible to debug the demo after MCU enter the low power mode.
I hope you can explain it, it can help me to figure the issue out.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------