diff options
Diffstat (limited to 'chip/stm32/pwm.c')
-rw-r--r-- | chip/stm32/pwm.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/chip/stm32/pwm.c b/chip/stm32/pwm.c index 073e2df511..5b3ba75f8f 100644 --- a/chip/stm32/pwm.c +++ b/chip/stm32/pwm.c @@ -81,10 +81,10 @@ static void pwm_configure(enum pwm_channel ch) * ARR determines the wave period, CCRn determines duty cycle. * Thus, frequency = cpu_freq / PSC / ARR. so: * - * frequency = cpu_freq / (cpu_freq/10000) / 100 = 100 Hz. + * frequency = cpu_freq / (cpu_freq/10000 + 1) / (99 + 1) = 100 Hz. */ - tim->psc = clock_get_freq() / 10000; - tim->arr = 100; + tim->psc = clock_get_freq() / 10000 - 1; + tim->arr = 99; if (pwm->channel <= 2) /* Channel ID starts from 1 */ ccmr = &tim->ccmr1; |