In one of the timer examples, the following is mentioned before an ISR definition:
* Note:
* We don't call the timer API here because they are not declared with IRAM_ATTR.
* If we're okay with the timer irq not being serviced while SPI flash cache is disabled,
* we can allocate this interrupt without the ESP_INTR_FLAG_IRAM flag and use the normal API.
*/
void IRAM_ATTR timer_group0_isr(void *para)
1) Does this mean that any ESP APIs that are not declared with IRAM_ATTR should never be used inside such ISRs? For e.g even many basic APIs such as esp_get_level, esp_set_level do not use the IRAM_ATTR attribute.
2) Same question for usage of user defined functions within these ISRs?
Api usage in IRAM_ATTR interrupts
Re: Api usage in IRAM_ATTR interrupts
For a full explanation, see here:
https://docs.espressif.com/projects/esp ... t-handlers
The short answer is:
https://docs.espressif.com/projects/esp ... t-handlers
The short answer is:
- The restriction of only calling functions in IRAM only applies if the ESP_INTR_FLAG_IRAM is provided when the interrupt is allocated via the esp_intr_alloc() function. If you don't set this flag, you can call any API from the ISR.
- The downside of this is that during a flash write operation (ie NVS updating a value, or some other flash API which has to perform an erase or a write), processing of non-IRAM-safe interrupts is deferred until after the operation completes (which may be a few tens of milliseconds in the worst case).
Re: Api usage in IRAM_ATTR interrupts
Thanks for the reply.
My question was specific to interrupts allocated using ESP_INTR_FLAG_IRAM.
So it seems like even other important functions such as memset or more importantly xQueueSendToBackFromISR cannot be used?
If yes, this does seem to limit the functionality of such ISRs quite a bit.
My question was specific to interrupts allocated using ESP_INTR_FLAG_IRAM.
So it seems like even other important functions such as memset or more importantly xQueueSendToBackFromISR cannot be used?
If yes, this does seem to limit the functionality of such ISRs quite a bit.
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: Api usage in IRAM_ATTR interrupts
FreeRTOS APIs are an exception, as FreeRTOS at the moment is integrally loaded into IRAM; you can safely call those functions.
Who is online
Users browsing this forum: Bing [Bot] and 82 guests