Browse Source

Fix TMC_HOME_PHASE divide by zero (#20368)

vanilla_fb_2.0.x
Jason Smith 4 years ago
committed by GitHub
parent
commit
21ee7b1c86
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      Marlin/src/module/motion.cpp

8
Marlin/src/module/motion.cpp

@ -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…
Cancel
Save