AnsweredAssumed Answered

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

Question asked by LIAN DAI on Dec 12, 2016
Latest reply on Jan 8, 2017 by Kerry Zhou

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();

}

Attachments

Outcomes