Timer

[中文]


What should I pay attention to when using the HW timer interrupt with ESP8266?

  • Please refer to ESP8266 Technical Reference Manual regarding the related APIs.

  • If you are using NonOS SDK, please refer to ESP8266 Non-OS SDK API Reference.

  • Typically, the hardware interrupt callback function needs to be executed as quickly as possible, and the callback function should be placed in IRAM to avoid the impact of Cache being turned off.

    • RTOS SDK requires adding the linker attribute IRAM_ATTR before the function name.

    • NonOS SDK cannot add ICACHE_FLASH_ATTR (this attribute specifies the function is placed in flash) before the function name.


How to set interrupt priority for timers?

  • The esp_timer, using ESP32 as an example, allows you to configure the interrupt priority by modifying the configuration item CONFIG_ESP_TIMER_INTERRUPT_LEVEL in Menuconfig.

  • The General Purpose Timer allows setting interrupt priority when registering the interrupt service function. For details, please refer to the API description of timer_isr_callback_add.