From 8a96a62c42708d5da7ce90e455531ec16986ee93 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 9 Dec 2015 15:05:02 +0100 Subject: [PATCH] cpu/stm32f4discovery: fixed freq return in pwm_init --- cpu/stm32f4/periph/pwm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpu/stm32f4/periph/pwm.c b/cpu/stm32f4/periph/pwm.c index eaf5e76b35..f317efb929 100644 --- a/cpu/stm32f4/periph/pwm.c +++ b/cpu/stm32f4/periph/pwm.c @@ -120,6 +120,8 @@ int pwm_init(pwm_t dev, pwm_mode_t mode, unsigned int frequency, unsigned int re } tim->PSC = (pwm_clk / (resolution * frequency)) - 1; tim->ARR = resolution - 1; + /* calculate the actual PWM frequency */ + frequency = (pwm_clk / (resolution * (tim->PSC + 1))); /* set PWM mode */ switch (mode) {