AnsweredAssumed Answered

LPC1769: interrupt on GPIO pin change

Question asked by danielholala on Jun 4, 2018
Latest reply on Aug 6, 2019 by danielholala



I'm developing on a LPCXpresso LPC1769 (OM13085) board using LPCOpen's chip specific drivers ("lpc_chip_175x_6x").



According to the manual, chapter 9: 

- Port 0 and Port 2 can provide a single interrupt for any combination of port pins.

-  Each port pin can be programmed to generate an interrupt on a rising edge, a falling edge, or both.

I'd like trigger an interrupt on both a rising edge and a falling edge on a GPIO pin signal.


However, when the ISR EINT3_IRQHandler() is called, GPIO interrupt status registers indicate a falling edge interrupt (register IO0IntStatF) and a rising edge interrupt (register IO0IntStatR).


Why is this?


This is my example code:


#include "chip.h"
#include <stdio.h>

/* use semi-hosting for printf() console output */

void EINT3_IRQHandler(void) {
    printf("GPIO IRQ Status:%08x ENF:%08x ENR:%08x\n",
    Chip_GPIOINT_ClearIntStatus(LPC_GPIOINT, GPIOINT_PORT0, 1 << 19);

int main(void) {

    // configure Pin P0.19 for interrupt on input signal change
    Chip_GPIOINT_ClearIntStatus(LPC_GPIOINT, GPIOINT_PORT0, 1 << 19);
    Chip_GPIOINT_SetIntFalling( LPC_GPIOINT, GPIOINT_PORT0, 1 << 19);
    Chip_GPIOINT_SetIntRising(  LPC_GPIOINT, GPIOINT_PORT0, 1 << 19);
    NVIC_ClearPendingIRQ(EINT3_IRQn); // avoid extraneous IRQ on restart

    volatile static int i = 0 ;
    Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 17); // Pin P0.17
    Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 22); // red led on board
    while(1) {
         Chip_GPIO_SetPinOutHigh(LPC_GPIO, 0, 17);
         Chip_GPIO_SetPinOutHigh(LPC_GPIO, 0, 22);
         for (i = 0; i< 10000000; i++) { }
         Chip_GPIO_SetPinOutLow(LPC_GPIO, 0, 17);
         Chip_GPIO_SetPinOutLow(LPC_GPIO, 0, 22);
         for (i = 0; i< 10000000; i++) { }
    return 0 ;

I wired GPIO output P0.17 to P0.19.

  • P0.17 is switched with a periode of about 3 seconds
  • The red LED on the eval board is also switched (for visual feedback)
  • P0.19 is configured for interrupt on both rising and falling edge
  • ISR prints interrupt status registers.

This is the output I get:

[MCUXpresso Semihosting Telnet console for 'Test02-newlib LinkServer Debug' started on port 60095 @]

GPIO IRQ Status:00000001 ENF:00080000 ENR:00080000
GPIO IRQ Status:00000001 ENF:00080000 ENR:00080000
GPIO IRQ Status:00000001 ENF:00080000 ENR:00080000

Thanks for your comments.