ASM example for ESP32-C3 ISR

jonsmirl
Posts: 19
Joined: Tue Dec 08, 2015 10:59 pm

ASM example for ESP32-C3 ISR

Postby jonsmirl » Sun Sep 26, 2021 1:57 pm

Can you please provide an example of how to code ISRs in ASM on ESP32-C3? There are examples for normal ESP32, but none for C3.

We need to process an interrupt in close to hard real-time. Receive interrupt on NMI every 18.66ms. Program PWM to generate delayed pulse from 0-18ms. Then return from ISR. Delay can be controlled by global variable.

The idea is to be as fast a possible with programming the PWM in the NMI ISR. Can this be made fast enough to not interfere with Wifi/BLE? Can this be chained onto the watchdog ISR?

No desire to write this in C or drop down into FreeRTOS. Only want to program the PWM hardware and return.

ESP_SRJ
Posts: 3
Joined: Sat Oct 09, 2021 8:19 am

Re: ASM example for ESP32-C3 ISR

Postby ESP_SRJ » Mon Oct 11, 2021 4:03 am

ESP32C3 is based on the RISC-V architecture, therefore, the way of how interrupts are processed in the ASM vector table is different than the way for ESP32 (Xtensa architecture). Basically, ESP32C3 allows for high-level interrupt handlers being coded in C, and there is no much time-benefit from writing the ISR (even NMI level interrupt) in ASM than writing in C for ESP32C3 chips. An NMI level interrupt only ensures it wouldn't be blocked by any critical sections, so you can still expect up to 2us for the interrupt overhead before getting to the ISR code, and up to 5us for interrupt delay if there happens a context switch (with WIFI/BLE).

Who is online

Users browsing this forum: No registered users and 174 guests