Skip to content

Commit 3f44e82

Browse files
committed
fix(timer): pause the channel before new PWM config
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 339e2b9 commit 3f44e82

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: libraries/SrcWrapper/src/HardwareTimer.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,9 @@ void HardwareTimer::setPWM(uint32_t channel, uint32_t pin, uint32_t frequency, u
936936
*/
937937
void HardwareTimer::setPWM(uint32_t channel, PinName pin, uint32_t frequency, uint32_t dutycycle, callback_function_t PeriodCallback, callback_function_t CompareCallback)
938938
{
939+
if (isRunningChannel(channel)) {
940+
pauseChannel(channel);
941+
}
939942
setMode(channel, TIMER_OUTPUT_COMPARE_PWM1, pin);
940943
setOverflow(frequency, HERTZ_FORMAT);
941944
setCaptureCompare(channel, dutycycle, PERCENT_COMPARE_FORMAT);

0 commit comments

Comments
 (0)