40 kHz GPIO interrupt
Posted: Fri Apr 19, 2019 11:28 am
How can I get a GPIO interrupt to pre-empt WiFi and RMT operations? I need high priority
I have tried using ESP_INTR_FLAG_LEVELn, but I get exceptions for even LEVEL1. Only the default flags, or IRAM flag work.
---
DETAIL:
We've got a 40 kHz clock running to an ESP32 GPIO pin, with an interrupt enabled. The interrupt reads data out of a bit buffer and sets another GPIO pin. It's to send raw data to a radio.
It is very important that this interrupt never be delayed, however I'm seeing occasional latency spikes in the interrupt on the order of ~1ms. I can only tolerate ~25us of jitter.
WiFi is connected in STA mode and I'm using RMT to transmit (to control some LEDs).
Here's how I'm enabling the interrupt. Note: rf_dclk_pin_callback and all functions it calls are declared with IRAM_ATTR (recursively).
I have tried using ESP_INTR_FLAG_LEVELn, but I get exceptions for even LEVEL1. Only the default flags, or IRAM flag work.
---
DETAIL:
We've got a 40 kHz clock running to an ESP32 GPIO pin, with an interrupt enabled. The interrupt reads data out of a bit buffer and sets another GPIO pin. It's to send raw data to a radio.
It is very important that this interrupt never be delayed, however I'm seeing occasional latency spikes in the interrupt on the order of ~1ms. I can only tolerate ~25us of jitter.
WiFi is connected in STA mode and I'm using RMT to transmit (to control some LEDs).
Here's how I'm enabling the interrupt. Note: rf_dclk_pin_callback and all functions it calls are declared with IRAM_ATTR (recursively).
static inline void IRAM_ATTR rf_enable_irq(bool enable)
{
gpio_config_t io_conf;
if (enable) {
//interrupt of rising edge
io_conf.intr_type = GPIO_PIN_INTR_POSEDGE;
io_conf.pin_bit_mask = (1ULL << RF_PIN_SI_CLK);
//set as input mode
io_conf.mode = GPIO_MODE_INPUT;
//enable pull-up mode
io_conf.pull_up_en = 1;
gpio_config(&io_conf);
//install gpio isr service
gpio_install_isr_service(ESP_INTR_FLAG_IRAM);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(RF_PIN_SI_CLK, rf_dclk_pin_callback, (void*) RF_PIN_SI_CLK);
} else {
gpio_isr_handler_remove(RF_PIN_SI_CLK);
}
}