Timer prescaler and PWM calculator

PSC and ARR for a frequency or period, error, PWM resolution and CCR for a duty cycle.

How to use it

  1. Enter the timer clock and the frequency or period you need.
  2. Pick a prescaler (PSC) and auto-reload (ARR) pair.
  3. Set a duty cycle to get the compare value (CCR) and see the PWM resolution.

Questions

Why add 1 to PSC and ARR?

On STM32 and similar timers the counter divides by PSC + 1 and counts ARR + 1 steps, so the registers hold one less than the divisor.

How fine can the duty cycle be?

One step in ARR + 1, that is log₂(ARR + 1) bits. A faster timer clock or a lower PWM frequency gives more steps.

Related tools

Lessons that explain it

Also useful for: psc, arr, ccr, auto-reload, period, duty cycle, interrupt rate, center aligned.