On the ESP32 interrupts are handled in two stages:
- Actual hardware interrupt calls c-code that effectively "sets a flag" to tell the RTOS to run the MicroPython interrupt handler code at some later time
- The RTOS, whenever it gets around to it, schedules the interrupt handler code written in MicroPython. That scheduling never happens when the GC is busy. Hence, on the ESP32, it is safe to allocate heap in interrupt service routines. Correct?
- (That's the good thing - the downside presumably is that this is one of the reasons for the very long interrupt latencies we are seeing on the ESP32. Would be interesting to see if there is a way around this, since presently they are comparable to what's seen under e.g. Linux - why not just use an rpi or something then, aside from power, size, cost.)