Stuck in IntDefaultHandler after Wakeup

cancel
Showing results for 
Search instead for 
Did you mean: 

Stuck in IntDefaultHandler after Wakeup

820 Views
f_fiorini
Contributor III

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! 

Labels (4)
10 Replies

426 Views
jeremyzhou
NXP TechSupport
NXP TechSupport

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

426 Views
f_fiorini
Contributor III

Hi jeremyzhou‌,
I was able to see that the code got stuck in the IntDefaultHandler because after I triggered an interrupt in pin 0.2 (connecting it to GND) I was able to pause the debug in the IDE, and I saw that it was executing that line. 

I hope to have cleared the question for you!
Thanks in advance for your help!

0 Kudos

426 Views
jeremyzhou
NXP TechSupport
NXP TechSupport

Hi Federico Fiorini ,

Thanks for your reply.
I was wondering if you can share the demo code, as I'd like to replicate the 'phenomeon' on my site.
I'm looking forward to your sharing.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

426 Views
f_fiorini
Contributor III

Hi jeremyzhou‌, 
have you tried running the code to replicate the problem? 

If you prefer I can send you a lighter version of the code, comprising only the required functions for deep sleep mode. 

Thanks in advance! 

0 Kudos

426 Views
jeremyzhou
NXP TechSupport
NXP TechSupport

Hi Federico Fiorini ,,

Please send a lighter code, the original one is a bit complicated.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

426 Views
f_fiorini
Contributor III

Hi jeremyzhou‌,
Here there is the lighter version of the code :smileyhappy:

Thanks in advance for your time!

0 Kudos

426 Views
jeremyzhou
NXP TechSupport
NXP TechSupport

Hi Federico Fiorini,

Thanks for your reply.
I'm afraid that you attached a wrong file.

pastedImage_1.png
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

426 Views
f_fiorini
Contributor III

That's odd, the file should be correct! 
I made another .zip file with the same code, but I deleted the .project file from CMSIS library so it has to be manually imported now.

I hope this works. 

In any case, I just discovered why it gets stuck in the DefaultIntHandler: my code is written in C++, so without putting "extern C" before the WAKEUP_IRQHandler the processor acts like the handler hasn't been defined.
After I did that, anyways, the code still gets stuck in the handler.
Apart from clearing the interrupt bits, what else should the interrupt do? Because I don't want my code to get stuck there indefinitely.

Thanks in advance! :smileyhappy:

0 Kudos

426 Views
jeremyzhou
NXP TechSupport
NXP TechSupport

Hi Federico Fiorini

Thanks for your reply.
No, I still can't import the project successfully, what a pity.
So I've attached a PMU demo which is written in C, you can migrate it to LPCXpresso to confirm the issue is related to the C++ or not.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

426 Views
f_fiorini
Contributor III

Hi jeremyzhou‌,
The demo code is attached to the comment! 

Since the deep sleep mode is part of a much bigger project I included all the code we are using, so if you think it's a bit messy let me know :smileywink:

Inside the zip file there is an indication of where to locate the needed files and classes (in the README file in the main folder) plus the settings we are using (in "settings.xml"), I imported them in the MCUXpresso project before coding! 

Thank you in advance! 
Kind regards

0 Kudos