GPIO Interrupt Won't Cause Sleep Mode to Exit

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

GPIO Interrupt Won't Cause Sleep Mode to Exit

529 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by keegan on Fri Mar 09 14:01:15 MST 2012
I've looked at the ext-int example provided for the LPC1343. I switched the pin corresponding to the interrupt to port 0.6 from the original, and verified that it still works. (LED changes when toggling the voltage on the pin 0.6).

From everything that I've heard about sleep mode, when you call __WFI(); the processor should go into sleep mode and then wake up whenever an enabled interrupt happens.

However, when I add __WFI(); inside the infinite loop in the extint example, it stops there and not even the interrupt handler gets called for P0.6.

Why is this happening? How do I properly enter sleep mode and have my code continue where it left off when there is an interrupt on P0.6?

Note, I'm not talking about "deep sleep mode", just regular old SLEEP Mode

int main (void)
{
  /* Basic chip initialization is taken care of in SystemInit() called
   * from the startup code. SystemInit() and chip settings are defined
   * in the CMSIS system_<part family>.c file.
   */

  /* Initialize GPIO (sets up clock) */
  GPIOInit();

   /* use port2_1 as input event, interrupt test. */
  GPIOSetDir( PORT0, 6, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT0, 6, 0, 0, 0 );
  GPIOIntEnable( PORT0, 6 );

  /* Set LED port line to output */
  GPIOSetDir( LED_PORT, LED_BIT, 1 );
  /* Turn LED on */
  GPIOSetValue( LED_PORT, LED_BIT, LED_ON );

  while( 1 ) {
  __WFI(); // STOPS HERE, NOTHING EVER HAPPENS AGAIN.
  }
}
0 Kudos
Reply
4 Replies

490 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sat Mar 10 11:46:12 MST 2012
The M3 should advertise a sleep status, but NXP either disabled or worked around this core behavior. In this case, the debugger misinterprets the sleep as an unrecoverable stall, and halts the part.  The fix for this didn't make it into your release, but should be available soon.

Regards,
CodeRedSupport
0 Kudos
Reply

490 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by keegan on Fri Mar 09 19:39:58 MST 2012
Correction.

This only happens when I am using the debugger.

So sleep mode does exit when I am powering the board directly, but not debugging using the LPC link.

The application notes say the lpc1343 "can't wake up in the usual manner when debugging", although it doesn't say that it's not possible. Also the __WFI() instruction is used in the blinky project, with a timer interrupt, and that still works even when using the debugger, so what's the difference here?
0 Kudos
Reply

490 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by keegan on Fri Mar 09 18:41:26 MST 2012
I've also read the application notes on entering sleep mode (Section 4.3)
http://www.nxp.com/documents/application_note/AN10973.pdf

If I follow their directions exactly for entering sleep mode, the effect is the same:


  while( 1 ) {
  LPC_PMU->PCON |= (1<<11); // clear Deep Power down flag
  SCB->SCR &= ~(1<<2); // clear sleepdeep bit
  __WFI();
  }

This document also states "Sleep mode is exited automatically when an interrupt enabled by the NVIC arrives at the processor or a reset occurs.

Does enabling the interrupt with IntEnable mean that the interrupt is enabled by the NVIC? If not, that is probably the problem, so how does one do this?
0 Kudos
Reply

490 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Fri Mar 09 16:20:56 MST 2012

Quote: keegan

Note, I'm not talking about "deep sleep mode", just regular old SLEEP Mode


Have you read the datasheet and made sure you're not entering deep sleep by accident?
0 Kudos
Reply