EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1006 background imageLoading...
Page #1006 background image
Chapter 2. API Reference
esp_timer_isr_dispatch_need_yield() function. The context switch will be done after all ISR
dispatch timers have been processed, if required by the system.
esp_timer during the light sleep
During light sleep, the esp_timer counter stops and no callback functions are called. Instead, the time is counted
by the RTC counter. Upon waking up, the system gets the difference between the counters and calls a function that
advances the esp_timer counter. Since the counter has been advanced, the system starts calling callbacks that were
not called during sleep. The number of callbacks depends on the duration of the sleep and the period of the timers.
It can lead to overflow of some queues. This only applies to periodic timers, one-shot timers will be called once.
This behavior can be changed by calling esp_timer_stop() before sleeping. In some cases, this can
be inconvenient, and instead of the stop function, you can use the skip_unhandled_events option during
esp_timer_create(). When the skip_unhandled_events is true, if a periodic timer expires one or more times
during light sleep then only one callback is called on wake.
Using the skip_unhandled_events option with automatic light sleep (see Power Management APIs) helps to reduce the
consumption of the system when it is in light sleep. The duration of light sleep is also determined by esp_timers.
Timers with skip_unhandled_events option will not wake up the system.
Handling callbacks
esp_timer is designed to achieve a high-resolution low latency timer and the ability to handle delayed events. If the
timer is late then the callback will be called as soon as possible, it will not be lost. In the worst case, when the timer has
not been processed for more than one period (for periodic timers), in this case the callbacks will be called one after
the other without waiting for the set period. This can be bad for some applications, and the skip_unhandled_events
option was introduced to eliminate this behavior. If skip_unhandled_events is set then a periodic timer that has expired
multiple times without being able to call the callback will still result in only one callback event once processing is
possible.
Obtaining Current Time
esp_timer also provides a convenience function to obtain the time passed since start-up, with microsecond pre-
cision: esp_timer_get_time(). This function returns the number of microseconds since esp_timer was
initialized, which usually happens shortly before app_main function is called.
Unlike gettimeofday function, values returned by esp_timer_get_time():
• Start from zero after the chip wakes up from deep sleep
• Do not have timezone or DST adjustments applied
Application Example
The following example illustrates usage of esp_timer APIs: system/esp_timer.
API Reference
Header File
• components/esp_timer/include/esp_timer.h
Functions
esp_err_t esp_timer_early_init(void)
Minimal initialization of esp_timer.
This function can be called very early in startup process, after this call only esp_timer_get_time function can
be used.
Espressif Systems 995
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish