diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 5fa88cb15..257132561 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -141,9 +141,10 @@ volatile signed char Stepper::count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; long Stepper::counter_m[MIXING_STEPPERS]; #endif -unsigned short Stepper::acc_step_rate; // needed for deceleration start point uint8_t Stepper::step_loops, Stepper::step_loops_nominal; -unsigned short Stepper::OCR1A_nominal; + +uint16_t Stepper::OCR1A_nominal, + Stepper::acc_step_rate; // needed for deceleration start point volatile long Stepper::endstops_trigsteps[XYZ]; @@ -711,12 +712,12 @@ void Stepper::isr() { NOMORE(acc_step_rate, current_block->nominal_rate); // step_rate to timer interval - const uint16_t timer = calc_timer(acc_step_rate); + const uint16_t interval = calc_timer_interval(acc_step_rate); - SPLIT(timer); // split step into multiple ISRs if larger than ENDSTOP_NOMINAL_OCR_VAL + SPLIT(interval); // split step into multiple ISRs if larger than ENDSTOP_NOMINAL_OCR_VAL _NEXT_ISR(ocr_val); - acceleration_time += timer; + acceleration_time += interval; #if ENABLED(LIN_ADVANCE) @@ -728,7 +729,7 @@ void Stepper::isr() { current_estep_rate[TOOL_E_INDEX] = ((uint32_t)acc_step_rate * current_block->abs_adv_steps_multiplier8) >> 17; #endif } - eISR_Rate = adv_rate(e_steps[TOOL_E_INDEX], timer, step_loops); + eISR_Rate = adv_rate(e_steps[TOOL_E_INDEX], interval, step_loops); #endif // LIN_ADVANCE } @@ -744,12 +745,12 @@ void Stepper::isr() { step_rate = current_block->final_rate; // step_rate to timer interval - const uint16_t timer = calc_timer(step_rate); + const uint16_t interval = calc_timer_interval(step_rate); - SPLIT(timer); // split step into multiple ISRs if larger than ENDSTOP_NOMINAL_OCR_VAL + SPLIT(interval); // split step into multiple ISRs if larger than ENDSTOP_NOMINAL_OCR_VAL _NEXT_ISR(ocr_val); - deceleration_time += timer; + deceleration_time += interval; #if ENABLED(LIN_ADVANCE) @@ -761,7 +762,7 @@ void Stepper::isr() { current_estep_rate[TOOL_E_INDEX] = ((uint32_t)step_rate * current_block->abs_adv_steps_multiplier8) >> 17; #endif } - eISR_Rate = adv_rate(e_steps[TOOL_E_INDEX], timer, step_loops); + eISR_Rate = adv_rate(e_steps[TOOL_E_INDEX], interval, step_loops); #endif // LIN_ADVANCE } diff --git a/Marlin/stepper.h b/Marlin/stepper.h index 030d503f5..617b3636a 100644 --- a/Marlin/stepper.h +++ b/Marlin/stepper.h @@ -138,10 +138,10 @@ class Stepper { #endif // !LIN_ADVANCE static long acceleration_time, deceleration_time; - //unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate; - static unsigned short acc_step_rate; // needed for deceleration start point static uint8_t step_loops, step_loops_nominal; - static unsigned short OCR1A_nominal; + + static uint16_t OCR1A_nominal, + acc_step_rate; // needed for deceleration start point static volatile long endstops_trigsteps[XYZ]; static volatile long endstops_stepsTotal, endstops_stepsDone; @@ -302,7 +302,7 @@ class Stepper { private: - FORCE_INLINE static unsigned short calc_timer(unsigned short step_rate) { + FORCE_INLINE static unsigned short calc_timer_interval(unsigned short step_rate) { unsigned short timer; NOMORE(step_rate, MAX_STEP_FREQUENCY); @@ -356,11 +356,11 @@ class Stepper { deceleration_time = 0; // step_rate to timer interval - OCR1A_nominal = calc_timer(current_block->nominal_rate); + OCR1A_nominal = calc_timer_interval(current_block->nominal_rate); // make a note of the number of step loops required at nominal speed step_loops_nominal = step_loops; acc_step_rate = current_block->initial_rate; - acceleration_time = calc_timer(acc_step_rate); + acceleration_time = calc_timer_interval(acc_step_rate); _NEXT_ISR(acceleration_time); #if ENABLED(LIN_ADVANCE)