Skip to content

ESP32 Timer Alarm Not Firing

DodaTech Updated 2026-06-26 1 min read

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

The Problem

ESP32 hardware timer alarm does not trigger the ISR or callback.

Quick Fix

Wrong

timer_init(TIMER_GROUP_0, TIMER_0, &config);
timer_start(TIMER_GROUP_0, TIMER_0);  // No alarm set
Timer counts but no alarm event fires.
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_enable_intr(TIMER_GROUP_0, TIMER_0);
timer_isr_register(TIMER_GROUP_0, TIMER_0, onTimer, NULL, 0, NULL);
timer_start(TIMER_GROUP_0, TIMER_0);
Timer fires every 10000 ticks (1 second at 8000 divider).

Prevention

Enable alarm with .alarm_en = TIMER_ALARM_EN. Register ISR before starting timer. Calculate correct divider for desired period (80 MHz / divider). Set auto_reload for repeating timers. Check return values of timer functions.

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

FAQ

### How do I calculate timer period?

Timer clock = 80 MHz / divider. At divider 8000: 10 kHz. Period = 1/10kHz = 100us per tick. Alarm at 10000 ticks = 1 second.

What is the max timer period?

Timer is 64-bit. At 80 MHz, max period is ~73,000 years. Practical limit is hardware interrupt overhead.

How many hardware timers does ESP32 have?

ESP32 has 2 timer groups, each with 2 timers. Total: 4 hardware timers. Each is 64-bit with independent divider.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro