From 982c4cbf7b3b27ccabf181d07c30e62d944b113e Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Thu, 21 Nov 2019 18:51:02 -0500 Subject: [PATCH] Candidate fix for homing fail hard reset --- Firmware/tmc2130.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 42359ba8..f64457b5 100755 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -807,15 +807,15 @@ void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_u { dir = tmc2130_get_inv(axis)?0:1; int steps = (int)step - (int)(mscnt >> shift); - if (steps < 0) - { - dir ^= 1; - steps = -steps; - } if (steps > static_cast(cnt / 2)) { dir ^= 1; - steps = cnt - steps; + steps = cnt - steps; // This can create a negative step value + } + if (steps < 0) + { + dir ^= 1; + steps = -steps; } cnt = steps; }