From e10a233c803acba2d92e24c624ced2a67fc2f875 Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Thu, 2 Jul 2020 14:54:09 +0200 Subject: [PATCH] STM32 PWM : avoid glitch after duty cycle change --- targets/TARGET_STM/pwmout_api.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/targets/TARGET_STM/pwmout_api.c b/targets/TARGET_STM/pwmout_api.c index 5739b6deb4..b8ce81a745 100644 --- a/targets/TARGET_STM/pwmout_api.c +++ b/targets/TARGET_STM/pwmout_api.c @@ -276,7 +276,9 @@ void pwmout_write(pwmout_t *obj, float value) } else { // If channel already enabled, only update compare value to avoid glitch __HAL_TIM_SET_COMPARE(&TimHandle, channel, sConfig.Pulse); + return; } + #if !defined(PWMOUT_INVERTED_NOT_SUPPORTED) if (obj->inverted) { HAL_TIMEx_PWMN_Start(&TimHandle, channel);