Unable to repeat deep sleep mode(woke up by external interrupt) using LPC1768

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to repeat deep sleep mode(woke up by external interrupt) using LPC1768

Jump to solution
590 Views
liandai
Contributor I

Hi Guys,

My system(currently using evaluation board MCB1700, LPC1768) will be powered by battery, so wanna make it work under deep sleep or power down mode.

Once the there is an external interrupt, the system should be woke up. After executed the desired instructions, I want to make it sleep deeply again.

Here are the codes I used.

It seems the first interrupt will be successfully triggered after pressing INT0 button. However, the chip won't be woke up again and sleep there forever. Interesting thing is if I put the chip into sleep mode instead of deep sleep mode, everything seems working normally.

The attachment shows my jumper setup.

Any idea why? 

I have to admit I'm a beginner to ARM CORTEX M3.

Thanks a lot.

Lian

int main(void)
{
uint32_t val;

SystemInit ();
PMU_Init(); //configure P2.10 as external interrupt input fallling edge triggered and configure LED Ports
PMU_Sleep(MCU_DEEP_SLEEP);// put power module unit into deep sleep mode

while(1)
{
__NOP;
}
}

/*****************************************************************************
** Function name: EINT0_Handler
**
** Descriptions: external INT handler
**
** parameters: None
** Returned value: None
**
*****************************************************************************/
void EINT0_IRQHandler (void)
{
static uint32_t tmp;
SystemInit ();  //after wakeup from deep sleep, the clock system should be reconfigured
LPC_SC->EXTINT = EINT0; /* clear interrupt */

tmp=(tmp?0:1);
GPIO_PinWrite(2,6,tmp);
PMU_Sleep(MCU_DEEP_SLEEP);// make it sleep again
return;

}

/*****************************************************************************
** Function name: PMU_Sleep
**
** Descriptions: Put some of the peripheral in sleep mode.
**
** parameters: SleepMode: 1 is deep sleep, 0 is sleep.
** Returned value: None
**
*****************************************************************************/

int PMU_Sleep( uint32_t SleepMode )
{
if ( SleepMode ){   

/*Set SLEEPDEEP bit in the Cortex M3 System Control Register*/
SCB->SCR |= 0x04;

/*PCON register + disable BOD*/
LPC_SC->PCON = 0x8; }

else
{
/*Clear the PCON*/
LPC_SC->PCON = 0x0;

/*Clear the SLEEPDEEP bit in the Cortex M3 System Control Register*/
SCB->SCR = 0x0;
}

__WFI();

}

0 Kudos
1 Solution
315 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Dear LIAN DAI, 

Thank you for your interest in NXP LPC product, I would like to provide service for you!

The question is the same question as what you have post in the case 00098569, that case is already solved after our discussion, now I post my answer from the case:
I have checked your code, some points need to take care:
1. Code modification
Please don't do much things in the interrupt handler.
You can use a flag, when the interrupt happens, then do the according things in the main code.
For example, you can define a global flag:volatile unsigned char flag_wakeup=0;
int main(void)
{
uint32_t val; SystemInit ();
PMU_Init(); //configure P2.10 as external interrupt input fallling edge triggered and configure LED Ports
PMU_Sleep(MCU_DEEP_SLEEP);// put power module unit into deep sleep mode
flag_wakeup=0;
while(1)
{
//__NOP;
   if( flag_wakeup == 1) // deep sleep is waked up
   {
     flag_wakeup=0;
     SystemInit (); //after wakeup from deep sleep, the clock system should be reconfigured
     PMU_Sleep(MCU_DEEP_SLEEP);// make it sleep again
 
   }}
} void EINT0_IRQHandler (void)
{ LPC_SC->EXTINT = EINT0; /* clear interrupt */
flag_wakeup = 1;}

2. After download the code to the chip with the debugger, please power off and power on again, don't just use the reset button.
 Please try it on your side again.Besides, I also create a project which can enter deep sleep, I have attached for your reference.
The code function is:
Power on the board, the LED P2.2 is blinking, at last the led is on, then enter the deep sleep mode, if the INT0 button is pressed, the LEDP2.2 will blink 2 times, then enter deep sleep again, wait the INIT0 happens, the cycle will repeat...
I have test in my MCB1769 board, the same as your MCB1768.
Wish it helps you!


Have a great day,
Kerry

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

View solution in original post

0 Kudos
3 Replies
316 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Dear LIAN DAI, 

Thank you for your interest in NXP LPC product, I would like to provide service for you!

The question is the same question as what you have post in the case 00098569, that case is already solved after our discussion, now I post my answer from the case:
I have checked your code, some points need to take care:
1. Code modification
Please don't do much things in the interrupt handler.
You can use a flag, when the interrupt happens, then do the according things in the main code.
For example, you can define a global flag:volatile unsigned char flag_wakeup=0;
int main(void)
{
uint32_t val; SystemInit ();
PMU_Init(); //configure P2.10 as external interrupt input fallling edge triggered and configure LED Ports
PMU_Sleep(MCU_DEEP_SLEEP);// put power module unit into deep sleep mode
flag_wakeup=0;
while(1)
{
//__NOP;
   if( flag_wakeup == 1) // deep sleep is waked up
   {
     flag_wakeup=0;
     SystemInit (); //after wakeup from deep sleep, the clock system should be reconfigured
     PMU_Sleep(MCU_DEEP_SLEEP);// make it sleep again
 
   }}
} void EINT0_IRQHandler (void)
{ LPC_SC->EXTINT = EINT0; /* clear interrupt */
flag_wakeup = 1;}

2. After download the code to the chip with the debugger, please power off and power on again, don't just use the reset button.
 Please try it on your side again.Besides, I also create a project which can enter deep sleep, I have attached for your reference.
The code function is:
Power on the board, the LED P2.2 is blinking, at last the led is on, then enter the deep sleep mode, if the INT0 button is pressed, the LEDP2.2 will blink 2 times, then enter deep sleep again, wait the INIT0 happens, the cycle will repeat...
I have test in my MCB1769 board, the same as your MCB1768.
Wish it helps you!


Have a great day,
Kerry

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

View solution in original post

0 Kudos
315 Views
liandai
Contributor I

Hi Kerry,

Thanks for your reply. Jingjing replied me two weeks ago, but I still want to say thanks.

Lian

0 Kudos
315 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Lian Dai,

   Kerry is Jingjing's English name.

   If your problem is solved, please help to mark the correct answer to close this question.

   Thank you!


Have a great day,
Kerry

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

0 Kudos