LPC1768 wake up from DeepSleep using a GPIO IRQ

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1768 wake up from DeepSleep using a GPIO IRQ

Jump to solution
888 Views
laurianussss
Contributor II

Hi

 

I am trying to wake up an LPC1768 using a GPIO IRQ from Deep sleep. Now it works but only using WDT and it resets the MCU. Also need help with what should I do the program to be resumed when IRQ is detected and not reset.

When I try to use a GPIO intrerupt it does not even reset it.

 

PINSEL_CFG_Type PinCfg;
PinCfg.Funcnum = 1;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = PINSEL_PINMODE_PULLUP;
PinCfg.Portnum = 2;

PinCfg.Pinnum = 10;
PINSEL_ConfigPin(&PinCfg);

NVIC_SetPriority(EINT0_IRQn, 0);
NVIC_ClearPendingIRQ(EINT0_IRQn);


LPC_PINCON->PINSEL4 |= (0x01 << 20); // function: EINT0
LPC_SC->EXTMODE |= ~(1 << 0); // Edge sensitive
//LPC_SC->EXTPOLAR &= ~(1 << 0); // falling-edge sensitive
LPC_SC->EXTPOLAR &= 1 << 0; // falling-edge sensitive

LPC_SC->EXTINT = (1 << 0); // clear flag

NVIC_EnableIRQ(EINT0_IRQn);

//---------- Disable and disconnect the main PLL0 before enter into Deep-Sleep
// or Power-Down mode <according to errata.lpc1768-16.March.2010> ------------

LPC_SC->PLL1CON = 2; // Turn off the main PLL (PLL0)
LPC_SC->PLL1FEED = 0xAA; // Feed
LPC_SC->PLL1FEED = 0x55; // Feed
while ((LPC_SC->PLL1STAT & (1<<9)) == 0); // Check connect bit status

LPC_SC->PLL0CON &= ~(1<<1); // Disconnect the main PLL (PLL0)
LPC_SC->PLL0FEED = 0xAA; // Feed
LPC_SC->PLL0FEED = 0x55; // Feed

while ((LPC_SC->PLL0STAT & (1<<25)) != 0x00); // Wait for main PLL (PLL0) to disconnect
LPC_SC->PLL0CON &= ~(1<<0); // Turn off the main PLL (PLL0)
LPC_SC->PLL0FEED = 0xAA; // Feed
LPC_SC->PLL0FEED = 0x55; // Feed
while ((LPC_SC->PLL0STAT & (1<<24)) != 0x00); // Wait for main PLL (PLL0) to shut down
//------------Then enter into PowerDown mode ----------------------------------


CLKPWR_DeepSleep();

 

 

void EINT0_IRQHandler(void)
{
NVIC_SystemReset();
}

 

 

Labels (2)
0 Kudos
Reply
1 Solution
841 Views
laurianussss
Contributor II

Thanks for reply. I found the problem after all. I was just need to disconnect debuger and make a power cycle. I was confused because watch dog wake up reset was working with debuger connected. Anyway GPIO wake up and continue the code was not working with debuger connected even after a power cycle. I think this was is not so clear explained in datasheet even now when I read it says something about this.

View solution in original post

0 Kudos
Reply
2 Replies
842 Views
laurianussss
Contributor II

Thanks for reply. I found the problem after all. I was just need to disconnect debuger and make a power cycle. I was confused because watch dog wake up reset was working with debuger connected. Anyway GPIO wake up and continue the code was not working with debuger connected even after a power cycle. I think this was is not so clear explained in datasheet even now when I read it says something about this.

0 Kudos
Reply
851 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @laurianussss 

How about testing the low - power demo under LPCopen on your side first?

 

88889999.jpg

It uses timer as wake up source.

 

BR

Alice

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2051038%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ELPC1768%20wake%20up%20from%20DeepSleep%20using%20a%20GPIO%20IRQ%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2051038%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EI%20am%20trying%20to%20wake%20up%20an%20LPC1768%20using%20a%20GPIO%20IRQ%20from%20Deep%20sleep.%20Now%20it%20works%20but%20only%20using%20WDT%20and%20it%20resets%20the%20MCU.%20Also%20need%20help%20with%20what%20should%20I%20do%20the%20program%20to%20be%20resumed%20when%20IRQ%20is%20detected%20and%20not%20reset.%3C%2FP%3E%3CP%3EWhen%20I%20try%20to%20use%20a%20GPIO%20intrerupt%20it%20does%20not%20even%20reset%20it.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EPINSEL_CFG_Type%20PinCfg%3B%3CBR%20%2F%3EPinCfg.Funcnum%20%3D%201%3B%3CBR%20%2F%3EPinCfg.OpenDrain%20%3D%200%3B%3CBR%20%2F%3EPinCfg.Pinmode%20%3D%20PINSEL_PINMODE_PULLUP%3B%3CBR%20%2F%3EPinCfg.Portnum%20%3D%202%3B%3CBR%20%2F%3E%3CBR%20%2F%3EPinCfg.Pinnum%20%3D%2010%3B%3CBR%20%2F%3EPINSEL_ConfigPin(%26amp%3BPinCfg)%3B%3CBR%20%2F%3E%3CBR%20%2F%3ENVIC_SetPriority(EINT0_IRQn%2C%200)%3B%3CBR%20%2F%3ENVIC_ClearPendingIRQ(EINT0_IRQn)%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ELPC_PINCON-%26gt%3BPINSEL4%20%7C%3D%20(0x01%20%26lt%3B%26lt%3B%2020)%3B%20%2F%2F%20function%3A%20EINT0%3CBR%20%2F%3ELPC_SC-%26gt%3BEXTMODE%20%7C%3D%20~(1%20%26lt%3B%26lt%3B%200)%3B%20%2F%2F%20Edge%20sensitive%3CBR%20%2F%3E%2F%2FLPC_SC-%26gt%3BEXTPOLAR%20%26amp%3B%3D%20~(1%20%26lt%3B%26lt%3B%200)%3B%20%2F%2F%20falling-edge%20sensitive%3CBR%20%2F%3ELPC_SC-%26gt%3BEXTPOLAR%20%26amp%3B%3D%201%20%26lt%3B%26lt%3B%200%3B%20%2F%2F%20falling-edge%20sensitive%3C%2FP%3E%3CP%3ELPC_SC-%26gt%3BEXTINT%20%3D%20(1%20%26lt%3B%26lt%3B%200)%3B%20%2F%2F%20clear%20flag%3CBR%20%2F%3E%3CBR%20%2F%3ENVIC_EnableIRQ(EINT0_IRQn)%3B%3C%2FP%3E%3CP%3E%2F%2F----------%20Disable%20and%20disconnect%20the%20main%20PLL0%20before%20enter%20into%20Deep-Sleep%3CBR%20%2F%3E%2F%2F%20or%20Power-Down%20mode%20%3CACCORDING%20to%3D%22%22%20errata.lpc1768-16.march.2010%3D%22%22%3E%20------------%3C%2FACCORDING%3E%3C%2FP%3E%3CP%3ELPC_SC-%26gt%3BPLL1CON%20%3D%202%3B%20%2F%2F%20Turn%20off%20the%20main%20PLL%20(PLL0)%3CBR%20%2F%3ELPC_SC-%26gt%3BPLL1FEED%20%3D%200xAA%3B%20%2F%2F%20Feed%3CBR%20%2F%3ELPC_SC-%26gt%3BPLL1FEED%20%3D%200x55%3B%20%2F%2F%20Feed%3CBR%20%2F%3Ewhile%20((LPC_SC-%26gt%3BPLL1STAT%20%26amp%3B%20(1%26lt%3B%26lt%3B9))%20%3D%3D%200)%3B%20%2F%2F%20Check%20connect%20bit%20status%3C%2FP%3E%3CP%3ELPC_SC-%26gt%3BPLL0CON%20%26amp%3B%3D%20~(1%26lt%3B%26lt%3B1)%3B%20%2F%2F%20Disconnect%20the%20main%20PLL%20(PLL0)%3CBR%20%2F%3ELPC_SC-%26gt%3BPLL0FEED%20%3D%200xAA%3B%20%2F%2F%20Feed%3CBR%20%2F%3ELPC_SC-%26gt%3BPLL0FEED%20%3D%200x55%3B%20%2F%2F%20Feed%3CBR%20%2F%3E%3CBR%20%2F%3Ewhile%20((LPC_SC-%26gt%3BPLL0STAT%20%26amp%3B%20(1%26lt%3B%26lt%3B25))%20!%3D%200x00)%3B%20%2F%2F%20Wait%20for%20main%20PLL%20(PLL0)%20to%20disconnect%3CBR%20%2F%3ELPC_SC-%26gt%3BPLL0CON%20%26amp%3B%3D%20~(1%26lt%3B%26lt%3B0)%3B%20%2F%2F%20Turn%20off%20the%20main%20PLL%20(PLL0)%3CBR%20%2F%3ELPC_SC-%26gt%3BPLL0FEED%20%3D%200xAA%3B%20%2F%2F%20Feed%3CBR%20%2F%3ELPC_SC-%26gt%3BPLL0FEED%20%3D%200x55%3B%20%2F%2F%20Feed%3CBR%20%2F%3Ewhile%20((LPC_SC-%26gt%3BPLL0STAT%20%26amp%3B%20(1%26lt%3B%26lt%3B24))%20!%3D%200x00)%3B%20%2F%2F%20Wait%20for%20main%20PLL%20(PLL0)%20to%20shut%20down%3CBR%20%2F%3E%2F%2F------------Then%20enter%20into%20PowerDown%20mode%20----------------------------------%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ECLKPWR_DeepSleep()%3B%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CP%3Evoid%20EINT0_IRQHandler(void)%3CBR%20%2F%3E%7B%3CBR%20%2F%3ENVIC_SystemReset()%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2051038%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EGeneral%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELPC17xx%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2054439%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20LPC1768%20wake%20up%20from%20DeepSleep%20using%20a%20GPIO%20IRQ%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2054439%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThanks%20for%20reply.%20I%20found%20the%20problem%20after%20all.%20I%20was%20just%20need%20to%20disconnect%20debuger%20and%20make%20a%20power%20cycle.%20I%20was%20confused%20because%20watch%20dog%20wake%20up%20reset%20was%20working%20with%20debuger%20connected.%20Anyway%20GPIO%20wake%20up%20and%20continue%20the%20code%20was%20not%20working%20with%20debuger%20connected%20even%20after%20a%20power%20cycle.%20I%20think%20this%20was%20is%20not%20so%20clear%20explained%20in%20datasheet%20even%20now%20when%20I%20read%20it%20says%20something%20about%20this.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2054330%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20LPC1768%20wake%20up%20from%20DeepSleep%20using%20a%20GPIO%20IRQ%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2054330%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CFONT%20face%3D%22times%20new%20roman%2Ctimes%22%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F247325%22%20target%3D%22_blank%22%3E%40laurianussss%3C%2FA%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22times%20new%20roman%2Ctimes%22%3E%3CSPAN%3EHow%20about%20testing%20the%20low%20-%20power%20demo%20under%20LPCopen%20on%20your%20side%20first%3F%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorAlice_Yang_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2288889999.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%2288889999.jpg%22%20style%3D%22width%3A%20351px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F326395i479336CCB324EB26%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2288889999.jpg%22%20alt%3D%2288889999.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%E2%80%83%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22times%20new%20roman%2Ctimes%22%3E%3CSPAN%3EIt%20uses%20timer%20as%20wake%20up%20source.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%3CFONT%20face%3D%22times%20new%20roman%2Ctimes%22%3E%3CSPAN%3EBR%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22times%20new%20roman%2Ctimes%22%3E%3CSPAN%3EAlice%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E