Page 1 of 1

Sending RMT pulses from ISR crashes if already transmitting

Posted: Wed Apr 03, 2019 6:11 pm
by DurandA
I am working on a PID controller that sends 100ns pulses to a TRIAC. Transmitting a rmt_item_t from an interrupt causes a reboot if another item is still transmitted:

Code: Select all

void IRAM_ATTR zerocross_isr_handler() {
    firing_pulse.duration0 = 7400;
    esp_err_t ret = rmt_wait_tx_done(firing_conf.channel, 0);
    if (ret==ESP_OK) {
        rmt_write_items(firing_conf.channel, &firing_pulse, 1, 0);
    }
}
If I reduce the duration to make sure that there is no previous transmission in progress, reboots stop. Note that only this interrupt sends items to the RMT. I tried to fix the issue using rmt_wait_tx_done(). However this seems to return ESP_OK anyway as the ESP keeps crashing.

I made a minimal example to demonstrate the issue: https://gist.github.com/DurandA/88cb4be ... 463bbc95ce

Re: Sending RMT pulses from ISR crashes if already transmitting

Posted: Thu Apr 04, 2019 1:40 am
by ESP_Sprite
You shouldn't call anything blocking from an ISR; in general, only trivial functions and the FreeRTOS *_from_isr() functions are safe. Suggest you fix this by setting a semaphore in the interrupt, then have a task blocking on this which sends the RMT pulse after.