Fix TMC_HOME_PHASE divide by zero (#20368)
This commit is contained in:
parent
a09d096b87
commit
1a618b1b31
@ -1490,10 +1490,12 @@ void set_axis_never_homed(const AxisEnum axis) {
|
||||
effectorBackoutDir, // Direction in which the effector mm coordinates move away from endstop.
|
||||
stepperBackoutDir; // Direction in which the TMC µstep count(phase) move away from endstop.
|
||||
|
||||
#define PHASE_PER_MICROSTEP(N) (256 / _MAX(1, N##_MICROSTEPS))
|
||||
|
||||
switch (axis) {
|
||||
#ifdef X_MICROSTEPS
|
||||
case X_AXIS:
|
||||
phasePerUStep = 256 / (X_MICROSTEPS);
|
||||
phasePerUStep = PHASE_PER_MICROSTEP(X);
|
||||
phaseCurrent = stepperX.get_microstep_counter();
|
||||
effectorBackoutDir = -X_HOME_DIR;
|
||||
stepperBackoutDir = INVERT_X_DIR ? effectorBackoutDir : -effectorBackoutDir;
|
||||
@ -1501,7 +1503,7 @@ void set_axis_never_homed(const AxisEnum axis) {
|
||||
#endif
|
||||
#ifdef Y_MICROSTEPS
|
||||
case Y_AXIS:
|
||||
phasePerUStep = 256 / (Y_MICROSTEPS);
|
||||
phasePerUStep = PHASE_PER_MICROSTEP(Y);
|
||||
phaseCurrent = stepperY.get_microstep_counter();
|
||||
effectorBackoutDir = -Y_HOME_DIR;
|
||||
stepperBackoutDir = INVERT_Y_DIR ? effectorBackoutDir : -effectorBackoutDir;
|
||||
@ -1509,7 +1511,7 @@ void set_axis_never_homed(const AxisEnum axis) {
|
||||
#endif
|
||||
#ifdef Z_MICROSTEPS
|
||||
case Z_AXIS:
|
||||
phasePerUStep = 256 / (Z_MICROSTEPS);
|
||||
phasePerUStep = PHASE_PER_MICROSTEP(Z);
|
||||
phaseCurrent = stepperZ.get_microstep_counter();
|
||||
effectorBackoutDir = -Z_HOME_DIR;
|
||||
stepperBackoutDir = INVERT_Z_DIR ? effectorBackoutDir : -effectorBackoutDir;
|
||||
|
Loading…
Reference in New Issue
Block a user