Apply fixes for DUE

Alternative to #7882. If F_CPU is greater than 1000 it can be evenly divided by 8. Over 10000, 16; over 100000, 32; over 1 million, 64; etc.
This commit is contained in:
Scott Lahteine
2017-10-07 13:34:25 -05:00
parent 4b36a542e0
commit 8315a8a716
8 changed files with 20 additions and 21 deletions

View File

@ -303,10 +303,9 @@ class Stepper {
#ifdef CPU_32_BIT
// In case of high-performance processor, it is able to calculate in real-time
timer = (uint32_t)(HAL_STEPPER_TIMER_RATE) / step_rate;
if (timer < (HAL_STEPPER_TIMER_RATE / (STEP_DOUBLER_FREQUENCY * 2))) { // (STEP_DOUBLER_FREQUENCY * 2 kHz - this should never happen)
timer = (HAL_STEPPER_TIMER_RATE / (STEP_DOUBLER_FREQUENCY * 2));
}
constexpr uint32_t MIN_TIME_PER_STEP = (HAL_STEPPER_TIMER_RATE) / ((STEP_DOUBLER_FREQUENCY) * 2);
timer = uint32_t(HAL_STEPPER_TIMER_RATE) / step_rate;
NOLESS(timer, MIN_TIME_PER_STEP); // (STEP_DOUBLER_FREQUENCY * 2 kHz - this should never happen)
#else
NOLESS(step_rate, F_CPU / 500000);
step_rate -= F_CPU / 500000; // Correct for minimal speed