From 4386d5cc706e36d9f069ae6124b88e3159f1d7bd Mon Sep 17 00:00:00 2001
From: Emilio Corigliano <emilio.corigliano@skywarder.eu>
Date: Wed, 11 Oct 2023 13:33:22 +0200
Subject: [PATCH] [CountedPWM] Non resetting the pulse counter so that we won't
 be stuck if we call generatePulses too frequently

---
 src/shared/drivers/timer/CountedPWM.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shared/drivers/timer/CountedPWM.cpp b/src/shared/drivers/timer/CountedPWM.cpp
index 9187f92bc..f5cc4f8c6 100644
--- a/src/shared/drivers/timer/CountedPWM.cpp
+++ b/src/shared/drivers/timer/CountedPWM.cpp
@@ -85,8 +85,8 @@ void CountedPWM::setDutyCycleResolution(unsigned int dutyCycleResolution)
 
 void CountedPWM::generatePulses(uint16_t pulses)
 {
-    // Reset the counters
-    pulseTimer.setCounter(0);
+    // Reset only the counter timer so that the pulses are generated always with
+    // the correct frequency and duty cycle
     counterTimer.setCounter(0);
 
     // Set the capture and compare register to the number of pulses to generate
-- 
GitLab