Removed unnecessary condition in timerCB, was aleady test on ´steps´

This commit is contained in:
Hakan Bastedt
2024-01-15 23:10:25 +01:00
parent 697ea19dae
commit 044e8fd2c5

View File

@@ -96,18 +96,15 @@ void StepGen::timerCB()
digitalWrite(dirPin, sgn); digitalWrite(dirPin, sgn);
double_t freqf = abs(steps) * (1e6 / double(timerNewCycleTime)); double_t freqf = abs(steps) * (1e6 / double(timerNewCycleTime));
uint32_t freq = uint32_t(freqf); uint32_t freq = uint32_t(freqf);
if (freq != 0) timerStepDirection = steps > 0 ? 1 : -1;
{ timerStepPositionAtEnd = timerNewEndStepPosition;
timerStepDirection = steps > 0 ? 1 : -1; timerNewEndStepPosition = 0; // Set to zero to not reload next time
timerStepPositionAtEnd = timerNewEndStepPosition; timerNewCycleTime = 0;
timerNewEndStepPosition = 0; // Set to zero to not reload next time MyTim->setMode(timerChan, TIMER_OUTPUT_COMPARE_PWM2, stepPin);
timerNewCycleTime = 0; MyTim->setOverflow(freq, HERTZ_FORMAT);
MyTim->setMode(timerChan, TIMER_OUTPUT_COMPARE_PWM2, stepPin); MyTim->setCaptureCompare(timerChan, 50, PERCENT_COMPARE_FORMAT); // 50 %
MyTim->setOverflow(freq, HERTZ_FORMAT); MyTim->resume();
MyTim->setCaptureCompare(timerChan, 50, PERCENT_COMPARE_FORMAT); // 50 % timerIsRunning = 1;
MyTim->resume();
timerIsRunning = 1;
}
} }
} }
if (timerStepPosition == timerStepPositionAtEnd) // Are we finished? if (timerStepPosition == timerStepPositionAtEnd) // Are we finished?