From 6d1aa4cad2e8dbc34b1366278fee3082d48a40f4 Mon Sep 17 00:00:00 2001 From: Karl Schwabe Date: Thu, 14 Sep 2017 08:31:01 +0200 Subject: [PATCH] Bugfix: corrects the ARR calculation for the LED PWM timer The calculation of the ARR on the LED PWM timer did not subtract 1 from the timer period calculation to get the ARR value. --- src/drivers/stm32/drv_led_pwm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drivers/stm32/drv_led_pwm.cpp b/src/drivers/stm32/drv_led_pwm.cpp index 016fdc57f6..3b7f74f400 100644 --- a/src/drivers/stm32/drv_led_pwm.cpp +++ b/src/drivers/stm32/drv_led_pwm.cpp @@ -147,14 +147,14 @@ static void led_pwm_timer_init_timer(unsigned timer) /* If the timer clock source provided as clock_freq is the STM32_APBx_TIMx_CLKIN * then configure the timer to free-run at 1MHz. - * Otherwize, other frequencies are attainable by adjusting .clock_freq accordingly. + * Otherwise, other frequencies are attainable by adjusting .clock_freq accordingly. */ rPSC(timer) = (led_pwm_timers[timer].clock_freq / 1000000) - 1; /* configure the timer to update at the desired rate */ - rARR(timer) = 1000000 / LED_PWM_RATE; + rARR(timer) = (1000000 / LED_PWM_RATE) - 1; /* generate an update event; reloads the counter and all registers */ rEGR(timer) = GTIM_EGR_UG;