All tools
TOOL IDB-SWE-003
PWM timer

Desktop only

Engineering tools are available only on desktop screens.

PWM timer setup

Prescaler, period (ARR), and duty register from MCU timer clock and target PWM frequency. Picks the smallest prescaler that fits the timer width, maximising resolution.

Counter ramp & PWM output ARR = — · CCR = —
CNT ARR CCR 0 PWM period duty
Engineering notes

Formulas

  • ARR = fclk / (prescaler × freq) − 1
  • CCR = (duty / 100) × (ARR + 1)
  • Resolution bits = log2(ARR + 1).

Picking prescaler

  • Smaller prescaler → finer resolution but ARR may not fit the timer width.
  • For motor PWM (15–30 kHz) aim for at least 10-bit resolution.
  • LED PWM works at 7–8 bit below ~1 kHz where flicker isn't visible.

Result

Live