How can I enable the interrupt of GPIO Port 1?

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

How can I enable the interrupt of GPIO Port 1?

1,056 Views
sudomona
Contributor I

Hi,
I am testing the Interrupt with LPC1114.
LPCOpen nxp_lpcxpresso_11c24_periph_pinint worked.
But GPIO Port1 any pin does not respond.

Is there anything I have to add something?

Thank you.

/* GPIO pin for GPIO pin interrupt */
#define GPIO_PININT_PORT 1 /* GPIO port number mapped to PININT */
#define GPIO_PININT 1 /* GPIO pin number mapped to PININT */
#define PININT_IRQ_HANDLER PIOINT0_IRQHandler /* GPIO interrupt IRQ function name */

void PININT_IRQ_HANDLER(void)
{
   /* Clear interrupt */
   Chip_GPIO_ClearInts(LPC_GPIO, GPIO_PININT_PORT, (1 << GPIO_PININT));
   Chip_GPIO_SetPinState(LPC_GPIO, 0, 7, true);
}

int main(void)
{
   SystemCoreClockUpdate();

   //LED
   Chip_GPIO_SetPinState(LPC_GPIO, 0, 7, false);
   Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 7);

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

   /* Configure channel interrupt as edge sensitive and falling edge interrupt */
   Chip_GPIO_SetupPinInt(LPC_GPIO, GPIO_PININT_PORT, GPIO_PININT, GPIO_INT_BOTH_EDGES);

   /* Enable GPIO pin intrerrupt */
   Chip_GPIO_EnableInt(LPC_GPIO, GPIO_PININT_PORT, (1 << GPIO_PININT));

   /* Enable all clocks, even those turned off at wake power up */
   Chip_SYSCTL_SetWakeup(~(SYSCTL_SLPWAKE_IRCOUT_PD | SYSCTL_SLPWAKE_IRC_PD |
   SYSCTL_SLPWAKE_FLASH_PD | SYSCTL_SLPWAKE_SYSOSC_PD | SYSCTL_SLPWAKE_SYSOSC_PD |    SYSCTL_SLPWAKE_SYSPLL_PD));

   /* Enable interrupt in the NVIC */
   NVIC_EnableIRQ(EINT0_IRQn);

   
   while (1) {
      __WFI();
   }
   return 0;
}

Labels (2)
0 Kudos
2 Replies

795 Views
soledad
NXP Employee
NXP Employee

Hi, 

Could you double check if you configure the pin as digital function mode?

Something like:

/* Configure pin as GPIO with pullup */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIN_ID,
(IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_DIGMODE_EN));

Have a great day,

Sol

 

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

0 Kudos

795 Views
sudomona
Contributor I

Thank you for your reply.

  Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_1, (IOCON_FUNC0 | IOCON_MODE_PULLDOWN | IOCON_DIGMODE_EN));

I added this configuration.

I tried both IOCON_MODE_PULLUP and IOCON_MODE_PULLDOWN, but did not reach the PININT_IRQ function.

I added GPIO_SetPinState to mainloop to check the reaction of PIO1_1.

It reacts.

while (1) {
   if (Chip_GPIO_GetPinState(LPC_GPIO, 1, 1))
      Chip_GPIO_SetPinState(LPC_GPIO, 0, 7, true);
   else
      Chip_GPIO_SetPinState(LPC_GPIO, 0, 7, false);
}

0 Kudos