This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC1788 Interrupts slow/mistimed

I'm having some difficulty with GPIO interrupts on an LPC1788 on the embedded artists development board.
I've reproduced the issue with a really stripped down project which is just looking at a clock signal coming in on one pin (~1200 Hz) and sending a pulse out on a different pin, and checking both on a oscilloscope.

the issue is that the interrupt should be firing on the falling edge of the clock signal and while it is firing, it effectively keeps shifting to the right relative to the signal going in, I have scope screenshots to illustrate the issue if it helps.
the code is:

#include "cmsis_os2.h"
#include "LPC177x_8x.h"
#include "GPIO_LPC17xx.h"
#include <stdio.h>

uint8_t clock_port = 0;
uint8_t clock_num = 9;
uint8_t twiddle_port = 1;
uint8_t twiddle_num = 28;

void GPIO_IRQHandler(void) {
        GPIO_PinWrite(twiddle_port, twiddle_num, 1);
        LPC_GPIOINT->IO0IntClr |= 1<<9;
        GPIO_PinWrite(twiddle_port, twiddle_num, 0);
}

int main() {
        osKernelInitialize();   // initialize CMSIS-RTOS

        SystemCoreClockUpdate();

        GPIO_PortClock(1);
        GPIO_SetDir(clock_port, clock_num, GPIO_DIR_INPUT);
        GPIO_SetDir(twiddle_port, twiddle_num, GPIO_DIR_OUTPUT);

        LPC_GPIOINT->IO0IntEnF |= 0x01 << 9; // trigger on falling edge
        NVIC_SetPriority(GPIO_IRQn, 0);
        NVIC_EnableIRQ(GPIO_IRQn);

        osKernelStart ();               // start thread execution

        for (;;) {

        }
        return 0;
}

I have tried this both with and without the RTOS initialised/started and see exactly the same behaviour with both.
for my application it is not possible to use the NMI pin or the external interrupts as I have 6 pins I need to work with this way.

the clock speed is 120MHz, the peripheral clock is 60MHz.
I was originally using keil 5.27.1, have now updated to 5.28.0.
all packs show as up to date.

am I missing something in my setup that explains the slow/mistimed interrupts?