AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Set timer resolution1/28/2024 Instead, use the esp_timer_isr_dispatch_need_yield() function. Timer callbacks that are processed by the ESP_TIMER_ISR method should not call the context switch call - portYIELD_FROM_ISR(). Keep the callback functions as short as possible. To restart a running timer, call esp_timer_stop() first, then call one of the start functions. Note that the timer must not be running when esp_timer_start_once() or esp_timer_start_periodic() is called. The timer keeps running until esp_timer_stop() is called. To start the timer in periodic mode, call esp_timer_start_periodic(), passing the period with which the callback should be called. When the callback gets called, the timer is considered to be stopped. To start the timer in one-shot mode, call esp_timer_start_once(), passing the time interval after which the callback should be called. The timer can be started in one-shot mode or in periodic mode. To delete the timer when it is no longer needed, call esp_timer_delete(). To create a timer, call esp_timer_create(). This callback function is called from the esp_timer task each time the timer elapses. Each timer has a callback function associated with it. Using esp_timer APIs Ī single timer is represented by esp_timer_handle_t type. Consider using dedicated hardware peripherals or DMA features if you find that a timer with a small period is required. Periodic software timers with a period of less than 50 us are not practical since they would consume most of the CPU time. Periodic esp_timer also imposes a 50 us restriction on the minimal timer period. If esp_timer_start_once() is called with a timeout value of less than 20 us, the callback will be dispatched only after approximately 20 us. Therefore, there is a lower limit to the timeout value of one-shot esp_timer. This method is useful for some simple callbacks which aim for lower latency.Ĭreating and starting a timer, and dispatching the callback takes some time. Timer callbacks are dispatched directly from the timer interrupt handler. For example, this will happen if an SPI Flash operation is in progress.ĮSP_TIMER_ISR. If other tasks with a priority higher than esp_timer are running, callback dispatching will be delayed until the esp_timer task has a chance to run. Because all the callbacks are dispatched from the same task, it is recommended to only do the minimal possible amount of work from the callback itself, posting an event to a lower-priority task using a queue instead. Timer callbacks are dispatched from a high-priority esp_timer task. Available only if CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is enabled (by default disabled).ĮSP_TIMER_TASK. Timer callbacks can be dispatched by two methods:ĮSP_TIMER_ISR. The exact hardware timer implementation used will depend on the target, where LAC timer is used for ESP32. Internally, esp_timer uses a 64-bit hardware timer. Raising the timer interrupt’s priority can reduce the timer processing delay caused by interrupt latency.Įsp_timer set of APIs provides one-shot and periodic timers, microsecond time resolution, and 64-bit range. The hardware timer interrupt’s priority is configured via the CONFIG_ESP_TIMER_INTERRUPT_LEVEL option (possible priorities being 1, 2, or 3). This necessitates the creation of an additional system on top of the hardware timer to keep track of pending events and ensure that callbacks are executed when the corresponding hardware interrupts occur. For instance, application components may require timer events to be triggered at specific future times, but hardware timers typically have only one “compare” value for interrupt generation. This task can be preempted by other tasks, leading to decreased precision and accuracy.Īlthough hardware timers are not subject to the limitations mentioned, they may not be as user-friendly. Timer callbacks are dispatched from a low-priority timer service (i.e., daemon) task. Maximum resolution is equal to the RTOS tick period Memory Management for MMU Supported MemoryĪlthough FreeRTOS provides software timers, FreeRTOS software timers have a few limitations:.
0 Comments
Read More
Leave a Reply. |