9 years, 11 months ago.

Interrupt delay

Dear all, Trying to solve the problem in my previous question: https://mbed.org/questions/3547/Trying-to-synchronise-a-signal/

I noticed that I have a huge delay (5uS) before anything happens after my interrupt. Also that resetting a timer seems to take about 1uS. I read somewhere that it should only take about 120nS before the interrupt routine is run. Do these delay sound normal to you? What's wrong? The delays I'm seeing would explain why my other code doesn't work.

This code:

#include "mbed.h"
#include "FastIO.h"

InterruptIn trigger(P0_23);
FastOut<P2_2> sync_out;

Timer clk;

void synch()
{
    sync_out = 1;
    sync_out = 0;
    clk.reset();
    sync_out = 1;
    sync_out = 0;
}

int main()
{
    clk.start();
    trigger.rise(&synch);

    while (1) {
    }

}

Gives this output (blue input trigger, yellow sync_out)

/media/uploads/geokonst/tek0001.jpg

If I recall correctly and they haven't changed it back, the LPC1768 interruptin code can handle something like up to 400kHz, so 2.5us delay. Less than what you see, but it quite a bit. Simply because it needs to find out on which pin the interrupt was called.

posted by Erik - 27 May 2014

@geo, as erik said there's overhead before your handler is called. Look at gpio implementation for LPC1768. You can import mbed-src and change it (not to iterate over all pins, but only used by our application). report back the timings then

posted by Martin Kojtal 28 May 2014
Be the first to answer this question.