Skip to content

Commit

Permalink
fix(timer): pause the channel before new PWM config
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic Pillon <[email protected]>
  • Loading branch information
fpistm committed Nov 19, 2024
1 parent 339e2b9 commit 3f44e82
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libraries/SrcWrapper/src/HardwareTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3f44e82

Please sign in to comment.