Calculadora de Timer/Prescaler MCU

Calcula frecuencia, período y overflow del timer a partir de clock del sistema, prescaler y ARR. Solucionador PWM inverso para encontrar prescaler/ARR/CCR óptimos. Presets para STM32, ESP32, Arduino, nRF52.

Main clock frequency of the MCU (before prescaler)

Clock divider value (actual division = PSC + 1 for STM32)

Timer counts from 0 to ARR, then reloads (period = ARR + 1)

Timer Frequency

1.000 kHz

Timer Period

1.000 ms

Overflow Time

1.000 ms

Timer Clock (after prescaler)

1.000 MHz

Counts per Overflow

1,000

Max Timer Period

59.6523 s

¿Tienes una sugerencia?

Solicita una nueva herramienta o sugiere mejoras — ¡únete a nuestra comunidad en Slack!

Dejar feedback en Slack

What is an MCU Timer / Prescaler Calculator?

An MCU Timer / Prescaler Calculator helps embedded systems engineers configure hardware timers in microcontrollers. Hardware timers are fundamental peripherals used for generating precise time delays, measuring pulse widths, creating PWM (Pulse Width Modulation) signals for motor control and LED dimming, and triggering periodic interrupts. The timer frequency is determined by the system clock divided by a prescaler and an auto-reload register (ARR). Since these values must be integers within specific ranges that vary by MCU family, finding the right combination to achieve a target frequency requires careful calculation — especially when the prescaler options are constrained to fixed values (as in Arduino/AVR) or powers of two (as in nRF52).

How to Use the MCU Timer Calculator

  1. Start by selecting your MCU from the Presets tab, or manually enter the system clock and timer bit width
  2. In the Timer Calculator tab, enter prescaler and ARR values to see the resulting frequency, period, and overflow time
  3. Use the PWM Calculator tab to enter your target frequency and duty cycle
  4. Click 'Find Optimal Settings' to get the best prescaler/ARR/CCR combination with the lowest error
  5. Review alternative settings that trade off between frequency accuracy and resolution
  6. View the interactive PWM waveform diagram showing the actual timing
  7. Apply preset MCU values directly to the Timer or PWM calculator tabs

Frequently Asked Questions

Why is the actual PWM frequency different from my target?

Timer registers (prescaler and ARR) can only hold integer values, so the actual frequency is the closest achievable approximation. For example, if you want exactly 50 kHz from a 72 MHz clock, the ideal ARR would be 1439 (72M / 50k - 1), giving exactly 50 kHz. But for 33 kHz, the ideal ARR would be ~2181.18 — rounding to 2181 gives 33.003 kHz (0.01% error). The calculator shows the actual achievable frequency and the error percentage.

What is the difference between PSC+1 and direct prescaler values?

STM32 and similar ARM-based MCUs use PSC+1 as the actual division factor (PSC=0 means divide-by-1, PSC=1 means divide-by-2). Arduino/AVR MCUs use fixed prescaler values like 1, 8, 64, 256, 1024 — you select from this set directly. nRF52 uses power-of-2 prescalers (1, 2, 4, 8, ..., 512). This calculator handles all conventions and shows register-ready values for your selected MCU.

How do I generate a 50 Hz PWM signal for servo motors?

Servo motors require a 50 Hz (20 ms period) PWM signal. For STM32F103 at 72 MHz: set prescaler to 71 (divide by 72, giving 1 MHz timer clock), then ARR to 19999 (20000 counts = 20 ms). For a typical servo range of 1-2 ms pulse width, CCR ranges from 1000 to 2000. For Arduino at 16 MHz: use prescaler 64 with a 16-bit timer, ARR=4999, giving exactly 50 Hz.

What happens if I need a very slow timer (seconds or minutes)?

For long periods, maximize both the prescaler and ARR values. A 16-bit timer can count to 65535, and with the maximum prescaler, you can achieve periods of several seconds. For STM32 at 72 MHz with PSC=65535 and ARR=65535: period = 65536 × 65536 / 72M ≈ 59.6 seconds. For longer periods, use 32-bit timers (STM32F4/H7) which can count to 4 billion, or chain multiple timers together.

Herramientas Relacionadas