Sending RMT pulses from ISR crashes if already transmitting

DurandA
Posts: 17
Joined: Thu Nov 26, 2015 11:51 pm

Sending RMT pulses from ISR crashes if already transmitting

Postby DurandA » Wed Apr 03, 2019 6:11 pm

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

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: Sending RMT pulses from ISR crashes if already transmitting

Postby ESP_Sprite » Thu Apr 04, 2019 1:40 am

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.

Who is online

Users browsing this forum: No registered users and 130 guests