How to wake up the system from deep sleep mode with pin interrupt?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to wake up the system from deep sleep mode with pin interrupt?

1,378 Views
Contributor II

What I’ve done is connecting the PIO1.0 to GND. However, I’m still not able to wake up the MCU. I’m not sure where I did wrong in the code. Please help me! Very much appreciated!


Summary of my code:
1. Setting PIO1.0 as pin interrupt, and then have the red LED light on indicating the this setting has been done.
2. num is for setting the sleep mode. The blue LED light will be on before going to deep sleep. After PIO 1.0 is connected to GND, the system will be woken up and UART0 will display text “WAKEUP”. And then the blue LED light will be on before going to deep sleep.


My EVB:
LPCXpresso11U68 OM13058

Code download:
https://drive.google.com/open?id=12ay_2-3bhIqHxvHi4gOAvLcs_3Rm1OyO

Code:

#include "board.h"

/* Mapped to PIO0_1, ISP_EN button on LPCXpresso board */
#define GPIO_PININT_PIN 0 /* GPIO pin number mapped to PININT */
#define GPIO_PININT_PORT 1 /* GPIO port number mapped to PININT */
#define GPIO_PININT_INDEX 0 /* PININT index used for GPIO mapping */

void PIN_INT0_IRQHandler(void)
{
      Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
      //Board_LED_Toggle(0);
}

int main(void)
{
uint32_t i,num;

SystemCoreClockUpdate();
Board_Init();
Board_LED_Set(0, 0);

//P1.0 Interrupt Wakeup---------------------------------------------------------------------------------------------
/* We'll use an optional IOCON filter (0) with a divider of 64 for the
input pin to be used for PININT */
Chip_Clock_SetIOCONFiltClockDiv(0, 64);

/* Configure GPIO pin as input */
Chip_GPIO_SetPinDIRInput(LPC_GPIO, GPIO_PININT_PORT, GPIO_PININT_PIN);

/* Configure pin as GPIO with pullup and use optional IOCON divider
0 with 3 filter clocks for input filtering */
Chip_IOCON_PinMuxSet(LPC_IOCON, GPIO_PININT_PORT, GPIO_PININT_PIN,
(IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_CLKDIV(0) | IOCON_S_MODE(3)));

/* Enable PININT clock */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PINT);

/* Configure interrupt channel for the GPIO pin in SysCon block */
Chip_SYSCTL_SetPinInterrupt(GPIO_PININT_INDEX, GPIO_PININT_PORT, GPIO_PININT_PIN);

Chip_SYSCTL_EnableStartPin(0);

/* Configure channel interrupt as edge sensitive and falling edge interrupt */
Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(GPIO_PININT_INDEX));

/* Enable interrupt in the NVIC */
NVIC_ClearPendingIRQ(PIN_INT0_IRQn);
NVIC_EnableIRQ(PIN_INT0_IRQn);

Board_LED_Set(0, 1);
for (i = 0; i < 4000000; i++);
for (i = 0; i < 4000000; i++);
for (i = 0; i < 4000000; i++);
Board_LED_Set(0, 0);

num = 1; //Select sleep mode 0:sleep 1:deep sleep

/* Go to sleep mode - LED will toggle on each wakeup event */
while (1)
{
      //sleep LED
      Board_LED_Set(2, 1);
      for (i = 0; i < 1800000; i++);
      Board_LED_Set(2, 0);

      switch (num)
      {
         case 0:
               DEBUGOUT("sleep mode\r\n\r\n");
               for (i = 0; i < 1800000; i++);

               Chip_PMU_SleepState(LPC_PMU);

               DEBUGOUT("sleep mode-WAKEUP\r\n\r\n");
               for (i = 0; i < 1800000; i++);
              break;
        case 1:
               DEBUGOUT("Deep Sleep mode\r\n\r\n");
               for (i = 0; i < 1800000; i++);

               /* We can optionally call Chip_SYSCTL_SetDeepSleepPD() to power down the
               BOD and WDT if we aren't using them in deep sleep modes. */
               Chip_SYSCTL_SetDeepSleepPD(SYSCTL_DEEPSLP_BOD_PD | SYSCTL_DEEPSLP_WDTOSC_PD);

               /* We should call Chip_SYSCTL_SetWakeup() to setup any peripherals we want
                  to power back up on wakeup. For this example, we'll power back up the IRC,
               FLASH, the system oscillator, and the PLL */
               Chip_SYSCTL_SetWakeup(~(SYSCTL_SLPWAKE_IRCOUT_PD | SYSCTL_SLPWAKE_IRC_PD |
               SYSCTL_SLPWAKE_FLASH_PD | SYSCTL_SLPWAKE_SYSOSC_PD |                SYSCTL_SLPWAKE_SYSPLL_PD));

               /* Enter MCU Deep Sleep mode */
               Chip_PMU_DeepSleepState(LPC_PMU);

               /* Power anything back up here that isn't powered up on wakeup. The example
               code below powers back up the BOD and WDT oscillator, which weren't setup to
                power up in the Chip_SYSCTL_SetWakeup() function. */
               Chip_SYSCTL_SetDeepSleepPD(0);

                DEBUGOUT("Deep Sleep mode-WAKEUP\r\n\r\n");
               for (i = 0; i < 1800000; i++);

               break;
         }

      }

return 0;

}

Labels (3)
0 Kudos
5 Replies

48 Views
NXP TechSupport
NXP TechSupport

Hi  Yen Milton ,

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.

To provide the fastest possible support, I'd highly recommend you to refer to the periph_pinint demo in the LPCOpen library.

LPCOpen Software for LPC11XX|NXP 

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

48 Views
Contributor II

Hi Jeremyzhou,

Thank you for reply. What I've done was using periph_pinint demo as base from LPCOpen library for my project. The pin interrupt from GPIO has been okay if I don't put the MCU into deep sleep mode. However, MCU cannot be woken up from deep sleep mode from pin interrupt from GPIO.


I put my project under google drive as follow:
https://drive.google.com/open?id=12ay_2-3bhIqHxvHi4gOAvLcs_3Rm1OyO

Please help!

pastedImage_2.png

0 Kudos

48 Views
NXP TechSupport
NXP TechSupport

Hi Yen Milton,

Thanks for your reply.

I've also replicated the phenomenon, in another similar question, AE colleague point out that the Pin interrupt is incapable of waking up the MCU from the Deep-sleep or Power-down mode.

And Developer can use the Grouped GPIO input interrupt instead of Pin interrupt as the wake source.

Please referring to the sample code for details.

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

48 Views
Contributor II

Hi Jeremyzhou

Test OK,Thank you.

0 Kudos

48 Views
Contributor II

Hi Jeremyzhou,

Thank you for your reply. I'll try it out.

0 Kudos