From a17fc44c7e551a1dfba095e7efd115067ebb0b91 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 21 Nov 2024 18:01:48 +0100 Subject: [PATCH] fix(hardwaretimer): resume if not running not only if previous mode is different. Signed-off-by: Frederic Pillon --- libraries/SrcWrapper/src/HardwareTimer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SrcWrapper/src/HardwareTimer.cpp b/libraries/SrcWrapper/src/HardwareTimer.cpp index 692397a196..be95bbf5ab 100644 --- a/libraries/SrcWrapper/src/HardwareTimer.cpp +++ b/libraries/SrcWrapper/src/HardwareTimer.cpp @@ -937,7 +937,7 @@ void HardwareTimer::setPWM(uint32_t channel, PinName pin, uint32_t frequency, ui if (CompareCallback) { attachInterrupt(channel, CompareCallback); } - if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) { + if (!isRunning() || !isRunningChannel(channel) || (previousMode != TIMER_OUTPUT_COMPARE_PWM1)) { resume(); } }