Chapter 2. API Reference
To pause the timer at any time, call timer_pause(). To resume it, call timer_start().
To reconfigure the timer, you can call timer_init(). This function is described in Section
You can also reconfigure the timer by using dedicated functions to change individual settings:
Set-
Dedicated
ting
Function
Di-
timer_set_divider()
vider
Mode
timer_set_counter_mode()
Auto
timer_set_auto_reload()
Reload
Alarms
To set an alarm, call the function
ing timer_set_alarm().
timer_init()
is called.
After the alarm is enabled, and the timer reaches the alarm value, the following two actions can occur depending on
the configuration:
• An interrupt will be triggered if previously configured. See Section
• When auto_reload is enabled, the timer's counter will automatically be reloaded to start
counting again from a previously configured value.
timer_set_counter_value().
Note:
• If an alarm value is set and the timer has already reached this value, the alarm is triggered immediately.
• Once triggered, the alarm is disabled automatically and needs to be re-enabled to trigger again.
To check the specified alarm value, call timer_get_alarm_value().
Interrupts
Registration of an interrupt callback for a specific timer can be done by calling
timer_isr_callback_add()
The callback handler will be invoked in ISR context, so user shouldn't put any blocking API in the callback
function. The benefit of using interrupt callback instead of precessing interrupt from scratch is, you don't have
to deal with interrupt status check and clean stuffs, they are all addressed before the callback got run in driver's
default interrupt handler.
For more information on how to use interrupts, please see the application example below.
Application Example
The 64-bit hardware timer example: peripherals/timer_group.
API Reference
Header File
•
components/driver/include/driver/timer.h
Espressif Systems
Description
Change the rate of ticking. To avoid unpredictable results, the timer should be paused
when changing the divider. If the timer is running,
it, change the setting, and start the timer again.
Set if the counter should be incrementing or decrementing
Set if the initial counter value should be reloaded on the timer's alarm
timer_set_alarm_value()
The alarm can also be enabled during the timer initialization stage, when
and passing in the group ID, timer ID, callback handler and user data.
Submit Document Feedback
timer_set_divider()
Interrupts
This value should be set in advance with
240
Timer
Initialization.
pauses
and then enable the alarm us-
on how to configure interrupts.
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?
Questions and answers