Content originally posted in LPCWare by dsquires@squires-eng.com on Thu Jul 11 12:23:40 MST 2013It 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->PINTSEL[0] = INTPIN_P1_27;
<span style="font-size: 10px;"> // Enable interrupts for both edges of P1.27</span>
LPC_GPIO_PIN_INT->ISEL = 0; // Sets pin interrupt mode to edge sensitive
LPC_GPIO_PIN_INT->IENR = 1; // Enable rising edge interrupt
LPC_GPIO_PIN_INT->SIENR = 1; // Write to enable rising edge interrupt
LPC_GPIO_PIN_INT->IENF = 1; // Enable falling edge interrupt
LPC_GPIO_PIN_INT->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 );
}