From 38a4c1e90b8c77f2d10f9ae559c28b6fd4578f98 Mon Sep 17 00:00:00 2001 From: Karl Schwabe Date: Mon, 11 Sep 2017 17:48:04 +0200 Subject: [PATCH] Bugfix: corrects the ARR calculation for the PWM timer The calculation of the ARR on the PWM timer did not subtract 1 from the timer period calculation to get the ARR value. --- src/drivers/stm32/drv_io_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/stm32/drv_io_timer.c b/src/drivers/stm32/drv_io_timer.c index f078cf83fc..a993db8e95 100644 --- a/src/drivers/stm32/drv_io_timer.c +++ b/src/drivers/stm32/drv_io_timer.c @@ -457,7 +457,7 @@ static int timer_set_rate(unsigned timer, unsigned rate) { /* configure the timer to update at the desired rate */ - rARR(timer) = BOARD_PWM_FREQ / rate; + rARR(timer) = (BOARD_PWM_FREQ / rate) - 1; /* generate an update event; reloads the counter and all registers */ rEGR(timer) = GTIM_EGR_UG;