Interrupt both edges on 13xx

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

Interrupt both edges on 13xx

875 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mozmck on Tue Aug 27 17:23:47 MST 2013
I'm moving a project from an LPC1114 to a LPC1347 chip, and I'm not sure how to set up a pin interrupt to interrupt on both edges - rising and falling edges.  Can I set it up so both rising and falling edge interrupts go to the same pin interrupt handler?  In the LPC1114 this was easy and straight-forward, but in the 13xx chips it is not clear and the sample code does not show any way to do it at all.

It looks like I should be able to just set the correct bit in both the IENF and IENR registers to enable both edges - will this work?

Thanks.
Labels (1)
0 Kudos
Reply
2 Replies

829 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mozmck on Wed Aug 28 18:36:22 MST 2013
Thanks, I thought that might work but was not sure.  I'll have boards to test with in a few days but thought I'd ask first and maybe save some time.
0 Kudos
Reply

829 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tha on Wed Aug 28 16:51:01 MST 2013
Hi Mozmck,

Yes, the pin interrupt will work with rising and falling edge.  You can use this little code snippet to test it out yourself:

#include "LPC13Uxx.h"/* LPC13Uxx Peripheral Registers */
#include "gpio.h"

int main (void)
{
  GPIOInit();

  /* use port0_1 as input event, interrupt test. */
  GPIOSetDir( PORT0, 1, 0 );
  /* channel 0, port0, bit 1, edge trigger, rising edge. */
  //Set P0_1 detect rising edge
  GPIOSetPinInterrupt( 0, 0, 1, 0, 1 );
  //Now set it for falling edge also
  LPC_GPIO_PIN_INT->IENF |= (0x1<<0);/* faling edge */

  GPIOPinIntEnable( 0, 1 );
  while(1);
}


You can monitor which edge is detected by setting a break point inside the PIN_INT0_IRQHandler() function.

The gpio.c file and gpio.h is from the code bundle.
0 Kudos
Reply