Skip to content

ESP32 Timer Auto-Reload Not Working

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 Timer Auto. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 timer fires once but does not reload and fire repeatedly.

Quick Fix

Wrong

timer_config_t config = {
  .auto_reload = TIMER_AUTORELOAD_DIS,  // Wrong!
Timer fires once then stops. No further alarms.
timer_config_t config = {
  .alarm_en = TIMER_ALARM_EN,
  .counter_en = TIMER_PAUSE,
  .intr_type = TIMER_INTR_LEVEL,
  .counter_dir = TIMER_COUNT_UP,
  .auto_reload = TIMER_AUTORELOAD_EN,
  .divider = 8000
};
timer_init(TIMER_GROUP_0, TIMER_0, &config);
timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, 10000);
timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0);
timer_enable_intr(TIMER_GROUP_0, TIMER_0);
timer_start(TIMER_GROUP_0, TIMER_0);
Timer fires every 1 second continuously until stopped.

Prevention

Set auto_reload = TIMER_AUTORELOAD_EN. Reset counter value with timer_set_counter_value(). Alarm value sets the reload target. Use auto_reload for PWM-like timing. Disable for one-shot timers.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What happens with auto reload disabled?

Timer counts to alarm value and stops. No further interrupts until counter is manually reset and timer restarted.

Can I change alarm value while running?

Yes. Call timer_set_alarm_value() while timer is running. The new value takes effect after the next reload.

How do I stop auto-reload?

Set .auto_reload = TIMER_AUTORELOAD_DIS in config, or call timer_set_alarm_reload() at runtime.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro