GPIO interrupt on a peripheral pin?

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

GPIO interrupt on a peripheral pin?

1,104 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cyberstudio on Thu Jun 06 04:06:45 MST 2013

If I have set up a pin as a peripheral pin (timer, uart, whatever) can I still setup GPIO edge-triggered interrupt on that pin? Thanks.

Labels (1)
0 Kudos
Reply
3 Replies

1,033 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dsquires@squires-eng.com on Thu Jul 11 12:23:40 MST 2013

It is definitely possible to configure an alternate function for a GPIO pin (like USART TXD) and also generate pin change interrupts from the same pin. 


We are doing this on the P1.27 TXD pin on an LPC11E14 device. We output USART serial data on the TXD pin but also generate interrupts on each edge of the TXD signal. In our application we don't even use the TXD signal directly at all.


Yes, you must have power enabled to the GPIO system and configure the alternate function for the pin as usual.


Here's our initialization for the pin change interrupts:


void init_txd_edge_int(void)


{


   NVIC_DisableIRQ( FLEX_INT0_IRQn );


 <span style="font-size: 10px;">   // Select P1.27 for pin interrupt selection 0</span>


   LPC_SYSCON-&gt;PINTSEL[0] = INTPIN_P1_27;


 <span style="font-size: 10px;">   // Enable interrupts for both edges of P1.27</span>


   LPC_GPIO_PIN_INT-&gt;ISEL    = 0;   // Sets pin interrupt mode to edge sensitive


   LPC_GPIO_PIN_INT-&gt;IENR    = 1;   // Enable rising edge interrupt


   LPC_GPIO_PIN_INT-&gt;SIENR   = 1;   // Write to enable rising edge interrupt


   LPC_GPIO_PIN_INT-&gt;IENF    = 1;   // Enable falling edge interrupt


   LPC_GPIO_PIN_INT-&gt;SIENF   = 1;   // Write to enable falling edge interrupt


 <span style="font-size: 10px;">   // Set P1.27 pin-change interrupt priority to 0 (highest) </span>


   // This is configured in decoder.h


   NVIC_SetPriority( FLEX_INT0_IRQn, TXD_PIN_CHANGE_NVIC_INT_PRIORITY );


 <span style="font-size: 10px;">   // Enable the pin change interrupt</span>


   NVIC_EnableIRQ( FLEX_INT0_IRQn );


}

0 Kudos
Reply

1,033 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mozmck on Thu Jun 13 15:09:30 MST 2013

I'm not so sure this is true, looking at the user manual.  You can read the DATA register and it will return the current logic state of the pins whether they are set to GPIO input, output, or some other function.  I don't see anything specifically about the interrupt in cases where the pin is set to some other function, but it would make sense that it triggers off the DATA register and operates the same way.  An easy way to check would be to set up and enable the GPIO interrupt on a UART pin and see if it calls the interrupt handler.  The GPIO domain would obviously have to be powered up.

0 Kudos
Reply

1,033 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tha on Thu Jun 06 10:41:31 MST 2013

When you assigned a pin to a specific fucntion other than GPIO, then the GPIO capabilities is considered disabled.  That's to say writing to the GPIO registers would have no affect on the pin after the function assignment.  Since the edge detection is part of the GPIO domain, this would also be disabled.


You can do a simple experiment to convince yourself on this:


Set up the UART on the TX/RX pin.  Now power down the GPIO domain.  With the GPIO domain powered down, the UART will still work.

0 Kudos
Reply