EasyManua.ls Logo

Espressif ESP32-S2 - General Purpose Timer

Espressif ESP32-S2
1695 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
enum dac_digi_convert_mode_t
DAC digital controller (DMA mode) work mode.
Values:
DAC_CONV_NORMAL
The data in the DMA buffer is simultaneously output to the enable channel of the DAC.
DAC_CONV_ALTER
The data in the DMA buffer is alternately output to the enable channel of the DAC.
DAC_CONV_MAX
2.2.3 General Purpose Timer
Introduction
The ESP32-S2 chip contains two hardware timer groups. Each group has two general-purpose hardware timer(s).
They are all 64-bit generic timers based on 16-bit pre-scalers and 64-bit up / down counters which are capable of
being auto-reloaded.
Functional Overview
The following sections of this document cover the typical steps to configure and operate a timer:
Timer Initialization - covers which parameters should be set up to get the timer working, and also what specific
functionality is provided depending on the timer configuration.
Timer Control - describes how to read a timers value, pause or start a timer, and change how it operates.
Alarms - shows how to set and use alarms.
Interrupts- explains how to use interrupt callbacks.
Timer Initialization The two ESP32-S2 timer groups, with two timer(s) in each, provide the total of four individual
timers for use. An ESP32-S2 timer group should be identified using timer_group_t. An individual timer in a
group should be identified with timer_idx_t.
First of all, the timer should be initialized by calling the function timer_init() and passing a structure
timer_config_t to it to define how the timer should operate. In particular, the following timer parameters
can be set:
Clock Source: Select the clock source, which together with the Divider define the resolution of the working
timer.
Divider: Sets how quickly the timers counter isticking. The setting divider is used as a divisor of the
clock source that by default is APB_CLK running at 80 MHz. For more information of APB_CLK frequency,
please check ESP32-S2 Technical Reference Manual > Reset and Clock [PDF] chapter for more details.
Mode: Sets if the counter should be incrementing or decrementing. It can be defined using counter_dir
by selecting one of the values from timer_count_dir_t.
Counter Enable: If the counter is enabled, it will start incrementing / decrementing immediately after calling
timer_init(). You can change the behavior with counter_en by selecting one of the values from
timer_start_t.
Alarm Enable: Can be set using alarm_en.
Auto Reload: Sets if the counter should auto_reload the initial counter value on the timers alarm or
continue incrementing or decrementing.
To get the current values of the timers settings, use the function timer_get_config().
Timer Control Once the timer is enabled, its counter starts running. To enable the timer, call the function
timer_init() with counter_en set to true, or call timer_start(). You can specify the timers
initial counter value by calling timer_set_counter_value(). To check the timers current value, call
timer_get_counter_value() or timer_get_counter_time_sec().
Espressif Systems 239
Submit Document Feedback
Release v4.4

Table of Contents