Page 1 of 2
External Interrupt Latency
Posted: Mon Nov 07, 2016 9:03 am
by jfmateos
I would like to know the interrupt latency for an external pin interrupt in ESP32.
Re: External Interrupt Latency
Posted: Mon Nov 07, 2016 11:36 am
by ESP_igrr
I have done a measurement and delay from external trigger to application-provided ISR handler is around 2us (at 240MHz clock), which is around 500 cycles.
Re: External Interrupt Latency
Posted: Mon Nov 07, 2016 7:26 pm
by jfmateos
That is pretty much slower than I could imagine.
Re: External Interrupt Latency
Posted: Wed Nov 09, 2016 3:23 am
by ESP_Sprite
Yep; due to the way the Xtensa architecture is designed, handling interrupts in C unfortunately takes a fair few instructions. We'll see if we can lower this number eventually. If you really really need quick interrupt responses, you can possibly copy the freertos component to your own project and write an assembly interrupt handler for one of the high-priority interrupts in xtensa-vectors.S.
Re: External Interrupt Latency
Posted: Wed Nov 09, 2016 8:26 am
by jfmateos
Thank you very much esp_sprite.
Unfortunately, that is far beyond my capabilities at this time
. I will study it in detail.
Re: External Interrupt Latency
Posted: Fri Jan 13, 2017 7:30 am
by chopin1998
ESP_igrr wrote:I have done a measurement and delay from external trigger to application-provided ISR handler is around 2us (at 240MHz clock), which is around 500 cycles.
yes, real interrupt delay is about 1.7~1.8uS, it seems too long for a 240Mhz processor,
I measure the delay on a 32Mhz 8bit mcu, delay is ~700nS...
Re: External Interrupt Latency
Posted: Tue Feb 28, 2017 3:49 am
by hpeteranvin
I wonder if anyone has by any chance measured the pin-to-pin latency for a minimal interrupt handler (e.g.: on interrupt load a value from a memory and feed it out a GPIO port) written in assembly. The MIPS chip I'd like to replace currently does it in 225 ns at 80 MHz (18 clock cycles), and any increase is likely to make things no longer work.
Re: External Interrupt Latency
Posted: Tue Feb 28, 2017 6:08 am
by ESP_Sprite
If you write it in assembly, it doesn't need to be that slow. The ESP32 has high-priority interrupts which basically save PC and then immediately invoke your assembly-level routine. I can't tell if 18 cycles is enough to do what you want, obviously, but there is a fair chance it's possible.
Re: External Interrupt Latency
Posted: Tue Feb 28, 2017 11:51 pm
by hpeteranvin
Just to clarify: I don't need to make the same cycle count, just the same wall time (so approx 36/54 cycles at 160/240 MHz).
To be specific, this application operates as a bus slave to an 8-bit legacy computer bus. The most time-critical handler operates as a RAM simulator: it gets an interrupt, reads address bits off 16 GPIs, looks up an internal 64K table, writes an 8-bit data values to GPIOs, and sets the GPIOs to output. That has to happen within the time frame I indicated in order to avoid a lot of additional external logic.
Re: External Interrupt Latency
Posted: Wed Mar 01, 2017 4:49 am
by ESP_Sprite
Ah, yes, obviously, I somehow managed to mix up APB clock and CPU clock. Maybe I'll whip up a quick try to see what our interrupt latency can be in high-prio interrupt mode later on, I'm curious about that as well. (If any because some
old projects of mine could perhaps use an upgrade...)