Skip to content
Commit e681f9cb authored by Florian Vaussard's avatar Florian Vaussard Committed by Kumar Gala
Browse files

pwm: stm32: fix off-by-one on PWM period



TimerHandle->Init.Period is used to initialize TIMx ARR register. The
timer will count from 0 up to ARR including, thus it will tick
(ARR + 1) timers per period. As the "period_cycles" variable holds the
number of desired ticks, the ARR register is computed as

ARR = period_cycles - 1

Update the code to reflect this relationship. Otherwise the timer will
count one more tick for each period, leading to a wrong PWM frequency.

Signed-off-by: default avatarFlorian Vaussard <florian.vaussard@gmail.com>
parent 85699f7c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment