diff --git a/libraries/SrcWrapper/src/HardwareTimer.cpp b/libraries/SrcWrapper/src/HardwareTimer.cpp index 7bb1da5dbf..ecaf44309b 100644 --- a/libraries/SrcWrapper/src/HardwareTimer.cpp +++ b/libraries/SrcWrapper/src/HardwareTimer.cpp @@ -936,6 +936,9 @@ void HardwareTimer::setPWM(uint32_t channel, uint32_t pin, uint32_t frequency, u */ void HardwareTimer::setPWM(uint32_t channel, PinName pin, uint32_t frequency, uint32_t dutycycle, callback_function_t PeriodCallback, callback_function_t CompareCallback) { + if (isRunningChannel(channel)) { + pauseChannel(channel); + } setMode(channel, TIMER_OUTPUT_COMPARE_PWM1, pin); setOverflow(frequency, HERTZ_FORMAT); setCaptureCompare(channel, dutycycle, PERCENT_COMPARE_FORMAT);