From 044e8fd2c50c6c655bb0446d50793953161f690f Mon Sep 17 00:00:00 2001 From: Hakan Bastedt Date: Mon, 15 Jan 2024 23:10:25 +0100 Subject: [PATCH] =?UTF-8?q?Removed=20unnecessary=20condition=20in=20timerC?= =?UTF-8?q?B,=20was=20aleady=20test=20on=20=C2=B4steps=C2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Firmware/src/StepGen.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Firmware/src/StepGen.cpp b/Firmware/src/StepGen.cpp index 4211e52..6957856 100755 --- a/Firmware/src/StepGen.cpp +++ b/Firmware/src/StepGen.cpp @@ -96,18 +96,15 @@ void StepGen::timerCB() digitalWrite(dirPin, sgn); double_t freqf = abs(steps) * (1e6 / double(timerNewCycleTime)); uint32_t freq = uint32_t(freqf); - if (freq != 0) - { - timerStepDirection = steps > 0 ? 1 : -1; - timerStepPositionAtEnd = timerNewEndStepPosition; - timerNewEndStepPosition = 0; // Set to zero to not reload next time - timerNewCycleTime = 0; - MyTim->setMode(timerChan, TIMER_OUTPUT_COMPARE_PWM2, stepPin); - MyTim->setOverflow(freq, HERTZ_FORMAT); - MyTim->setCaptureCompare(timerChan, 50, PERCENT_COMPARE_FORMAT); // 50 % - MyTim->resume(); - timerIsRunning = 1; - } + timerStepDirection = steps > 0 ? 1 : -1; + timerStepPositionAtEnd = timerNewEndStepPosition; + timerNewEndStepPosition = 0; // Set to zero to not reload next time + timerNewCycleTime = 0; + MyTim->setMode(timerChan, TIMER_OUTPUT_COMPARE_PWM2, stepPin); + MyTim->setOverflow(freq, HERTZ_FORMAT); + MyTim->setCaptureCompare(timerChan, 50, PERCENT_COMPARE_FORMAT); // 50 % + MyTim->resume(); + timerIsRunning = 1; } } if (timerStepPosition == timerStepPositionAtEnd) // Are we finished?