esp-idf/examples/peripherals/timer_group/legacy_driver
morris bc2a2d3cde gptimer: support RC_FAST clock source
GPTimer on C6 supports RC_FAST as the clock source. The benefit of this
clock is that, the clock can sustain in light sleep.

Added a new API to return the real resolution of the timer handle.
2022-12-26 13:18:25 +08:00
..
main esp_hw_support: Remove compare_set.h API 2022-07-22 00:06:06 +08:00
CMakeLists.txt tools: Increase the minimal supported CMake version to 3.16 2022-06-01 06:35:02 +00:00
pytest_timer_group.py gptimer: support RC_FAST clock source 2022-12-26 13:18:25 +08:00
README.md ci: Enable esp32c6 example, test_apps, and unit tests CI build stage 2022-11-01 11:23:21 +08:00
sdkconfig.defaults timer: disable nano printf for gptimer examples 2022-06-02 11:08:59 +08:00

Supported Targets ESP32 ESP32-C2 ESP32-C3 ESP32-C6 ESP32-S2 ESP32-S3

Example: General Purpose Timer

This example uses the timer group driver to generate timer interrupts at two specified alarm intervals.

How to Use Example

Hardware Required

  • A development board with ESP SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
  • A USB cable for Power supply and programming

Build and Flash

Run idf.py -p PORT flash monitor to build, flash and monitor the project.

(To exit the serial monitor, type Ctrl-].)

See the ESP-IDF Getting Started Guide for all the steps to configure and use the ESP-IDF to build projects.

Example Output

I (0) cpu_start: Starting scheduler on APP CPU.
I (325) example: Init timer with auto-reload
I (835) example: Timer auto reloaded, count value in ISR: 3
I (1335) example: Timer auto reloaded, count value in ISR: 3
I (1835) example: Timer auto reloaded, count value in ISR: 3
I (2335) example: Timer auto reloaded, count value in ISR: 3
I (2335) example: Init timer without auto-reload
I (2835) example: Timer alarmed at 500003
I (3335) example: Timer alarmed at 1000003
I (3835) example: Timer alarmed at 1500003
I (4335) example: Timer alarmed at 2000003

Functionality Overview

  • Configure one timer with auto-reload enabled, alarm period set to 0.5s
  • On reaching the interval value the timer will generate an alarm
  • The timer will reload with initial count value on alarm, by hardware
  • Reconfigure the timer with auto-reload disabled, initial alarm value set to 0.5s
  • The timer keeps incrementing and in the alarm callback, the software reconfigures its alarm value by increasing 0.5s
  • The main task will print the count value that captured in the alarm callback

Troubleshooting

For any technical queries, please open an issue on GitHub. We will get back to you soon.