From ba39186364b69f7399f33b7ddb1115db42c6eabc Mon Sep 17 00:00:00 2001 From: LinFor Date: Wed, 20 Feb 2019 11:22:42 +0300 Subject: [PATCH] TMC_DEBUG optimization and improvements (#13135) --- Marlin/src/feature/tmc_util.cpp | 336 ++++++++++++++------- Marlin/src/feature/tmc_util.h | 6 +- Marlin/src/gcode/feature/L6470/M122.cpp | 2 +- Marlin/src/gcode/feature/trinamic/M122.cpp | 5 +- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/inc/Conditionals_post.h | 7 +- Marlin/src/module/stepper_indirection.cpp | 4 + 7 files changed, 240 insertions(+), 122 deletions(-) diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index f344e95cf..ac956ad17 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -36,7 +36,7 @@ #include "../module/planner.h" #include "../libs/hex_print_routines.h" #if ENABLED(MONITOR_DRIVER_STATUS) - static bool report_tmc_status; // = false; + static uint16_t report_tmc_status_interval; // = 0 #endif #endif @@ -55,87 +55,159 @@ struct TMC_driver_data { uint32_t drv_status; - bool is_otpw, - is_ot, - is_s2ga, - is_s2gb, - is_error; + bool is_otpw:1, + is_ot:1, + is_s2g:1, + is_error:1 + #if ENABLED(TMC_DEBUG) + , is_stall:1 + , is_stealth:1 + , is_standstill:1 + #if HAS_STALLGUARD + , sg_result_reasonable:1 + #endif + #endif + ; + #if ENABLED(TMC_DEBUG) + #if HAS_TMCX1X0 || HAS_DRIVER(TMC2208) + uint8_t cs_actual; + #endif + #if HAS_STALLGUARD + uint16_t sg_result; + #endif + #endif }; - #if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) + + #if HAS_TMCX1X0 + #if ENABLED(TMC_DEBUG) static uint32_t get_pwm_scale(TMC2130Stepper &st) { return st.PWM_SCALE(); } - static uint8_t get_status_response(TMC2130Stepper &st, uint32_t) { return st.status_response & 0xF; } #endif + static TMC_driver_data get_driver_data(TMC2130Stepper &st) { - constexpr uint32_t OTPW_bm = 0x4000000UL; - constexpr uint8_t OTPW_bp = 26; - constexpr uint32_t OT_bm = 0x2000000UL; - constexpr uint8_t OT_bp = 25; - constexpr uint8_t S2GA_bp = 27; - constexpr uint8_t S2GB_bp = 28; + constexpr uint16_t SG_RESULT_bm = 0x3FF; // 0:9 + constexpr uint8_t STEALTH_bp = 14, CS_ACTUAL_sb = 16; + constexpr uint32_t CS_ACTUAL_bm = 0x1F0000; // 16:20 + constexpr uint8_t STALL_GUARD_bp = 24, OT_bp = 25, OTPW_bp = 26; + constexpr uint32_t S2G_bm = 0x18000000; + constexpr uint8_t STST_bp = 31; TMC_driver_data data; data.drv_status = st.DRV_STATUS(); - data.is_otpw = (data.drv_status & OTPW_bm) >> OTPW_bp; - data.is_ot = (data.drv_status & OT_bm) >> OT_bp; - data.is_s2ga = (data.drv_status >> S2GA_bp) & 0b1; - data.is_s2gb = (data.drv_status >> S2GB_bp) & 0b1; + #ifdef __AVR__ + // 8-bit optimization saves up to 70 bytes of PROGMEM per axis + uint8_t spart; + #if ENABLED(TMC_DEBUG) + data.sg_result = data.drv_status & SG_RESULT_bm; + spart = data.drv_status >> 8; + data.is_stealth = !!(spart & _BV(STEALTH_bp - 8)); + spart = data.drv_status >> 16; + data.cs_actual = spart & (CS_ACTUAL_bm >> 16); + #endif + spart = data.drv_status >> 24; + data.is_ot = !!(spart & _BV(OT_bp - 24)); + data.is_otpw = !!(spart & _BV(OTPW_bp - 24)); + data.is_s2g = !!(spart & (S2G_bm >> 24)); + #if ENABLED(TMC_DEBUG) + data.is_stall = !!(spart & _BV(STALL_GUARD_bp - 24)); + data.is_standstill = !!(spart & _BV(STST_bp - 24)); + data.sg_result_reasonable = !data.is_standstill; // sg_result has no reasonable meaning while standstill + #endif + + #else // !__AVR__ + + data.is_ot = !!(data.drv_status & _BV(OT_bp)); + data.is_otpw = !!(data.drv_status & _BV(OTPW_bp)); + data.is_s2g = !!(data.drv_status & S2G_bm); + #if ENABLED(TMC_DEBUG) + data.sg_result = data.drv_status & SG_RESULT_bm; + data.is_stealth = !!(data.drv_status & _BV(STEALTH_bp)); + data.cs_actual = (data.drv_status & CS_ACTUAL_bm) >> CS_ACTUAL_sb; + data.is_stall = !!(data.drv_status & _BV(STALL_GUARD_bp)); + data.is_standstill = !!(data.drv_status & _BV(STST_bp)); + data.sg_result_reasonable = !data.is_standstill; // sg_result has no reasonable meaning while standstill + #endif + + #endif // !__AVR__ + return data; } - #endif + + #endif // HAS_TMCX1X0 + #if HAS_DRIVER(TMC2208) + #if ENABLED(TMC_DEBUG) static uint32_t get_pwm_scale(TMC2208Stepper &st) { return st.pwm_scale_sum(); } - static uint8_t get_status_response(TMC2208Stepper &st, uint32_t drv_status) { - uint8_t gstat = st.GSTAT(); - uint8_t response = 0; - response |= (drv_status >> (31 - 3)) & 0b1000; - response |= gstat & 0b11; - return response; - } #endif + static TMC_driver_data get_driver_data(TMC2208Stepper &st) { - constexpr uint32_t OTPW_bm = 0b1ul; - constexpr uint8_t OTPW_bp = 0; - constexpr uint32_t OT_bm = 0b10ul; - constexpr uint8_t OT_bp = 1; - constexpr uint8_t S2GA_bp = 2; - constexpr uint8_t S2GB_bp = 3; + constexpr uint8_t OTPW_bp = 0, OT_bp = 1; + constexpr uint8_t S2G_bm = 0b11110; // 2..5 + constexpr uint8_t CS_ACTUAL_sb = 16; + constexpr uint32_t CS_ACTUAL_bm = 0x1F0000; // 16:20 + constexpr uint8_t STEALTH_bp = 30, STST_bp = 31; TMC_driver_data data; data.drv_status = st.DRV_STATUS(); - data.is_otpw = (data.drv_status & OTPW_bm) >> OTPW_bp; - data.is_ot = (data.drv_status & OT_bm) >> OT_bp; - data.is_s2ga = (data.drv_status >> S2GA_bp) & 0b1; - data.is_s2gb = (data.drv_status >> S2GB_bp) & 0b1; + data.is_otpw = !!(data.drv_status & _BV(OTPW_bp)); + data.is_ot = !!(data.drv_status & _BV(OT_bp)); + data.is_s2g = !!(data.drv_status & S2G_bm); + #if ENABLED(TMC_DEBUG) + #ifdef __AVR__ + // 8-bit optimization saves up to 12 bytes of PROGMEM per axis + uint8_t spart = data.drv_status >> 16; + data.cs_actual = spart & (CS_ACTUAL_bm >> 16); + spart = data.drv_status >> 24; + data.is_stealth = !!(spart & _BV(STEALTH_bp - 24)); + data.is_standstill = !!(spart & _BV(STST_bp - 24)); + #else + data.cs_actual = (data.drv_status & CS_ACTUAL_bm) >> CS_ACTUAL_sb; + data.is_stealth = !!(data.drv_status & _BV(STEALTH_bp)); + data.is_standstill = !!(data.drv_status & _BV(STST_bp)); + #endif + #if HAS_STALLGUARD + data.sg_result_reasonable = false; + #endif + #endif return data; } - #endif + + #endif // TMC2208 + #if HAS_DRIVER(TMC2660) + #if ENABLED(TMC_DEBUG) static uint32_t get_pwm_scale(TMC2660Stepper) { return 0; } - static uint8_t get_status_response(TMC2660Stepper, uint32_t drv_status) { - return drv_status & 0xFF; - } #endif + static TMC_driver_data get_driver_data(TMC2660Stepper &st) { - constexpr uint32_t OTPW_bm = 0x4UL; - constexpr uint8_t OTPW_bp = 2; - constexpr uint32_t OT_bm = 0x2UL; - constexpr uint8_t OT_bp = 1; + constexpr uint8_t STALL_GUARD_bp = 0; + constexpr uint8_t OT_bp = 1, OTPW_bp = 2; + constexpr uint8_t S2G_bm = 0b11000; + constexpr uint8_t STST_bp = 7, SG_RESULT_sp = 10; + constexpr uint32_t SG_RESULT_bm = 0xFFC00; // 10:19 TMC_driver_data data; data.drv_status = st.DRVSTATUS(); - data.is_otpw = (data.drv_status & OTPW_bm) >> OTPW_bp; - data.is_ot = (data.drv_status & OT_bm) >> OT_bp; + uint8_t spart = data.drv_status & 0xFF; + data.is_otpw = !!(spart & _BV(OTPW_bp)); + data.is_ot = !!(spart & _BV(OT_bp)); + data.is_s2g = !!(data.drv_status & S2G_bm); + #if ENABLED(TMC_DEBUG) + data.is_stall = !!(spart & _BV(STALL_GUARD_bp)); + data.is_standstill = !!(spart & _BV(STST_bp)); + data.sg_result = (data.drv_status & SG_RESULT_bm) >> SG_RESULT_sp; + data.sg_result_reasonable = true; + #endif return data; } - #endif + + #endif // TMC2660 #if ENABLED(STOP_ON_ERROR) void report_driver_error(const TMC_driver_data &data) { SERIAL_ECHOPGM(" driver error detected: 0x"); SERIAL_PRINTLN(data.drv_status, HEX); if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature"); - if (data.is_s2ga) SERIAL_ECHOLNPGM("short to ground (coil A)"); - if (data.is_s2gb) SERIAL_ECHOLNPGM("short to ground (coil B)"); + if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit"); #if ENABLED(TMC_DEBUG) tmc_report_all(true, true, true, true); #endif @@ -162,61 +234,79 @@ void report_polled_driver_data(TMC &st, const TMC_driver_data &data) { const uint32_t pwm_scale = get_pwm_scale(st); st.printLabel(); - SERIAL_ECHOPAIR(":", pwm_scale); - SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st, data.drv_status), BIN); - SERIAL_ECHOPGM("| "); - if (st.error_count) SERIAL_CHAR('E'); - else if (data.is_ot) SERIAL_CHAR('O'); - else if (data.is_otpw) SERIAL_CHAR('W'); - else if (st.otpw_count > 0) SERIAL_PRINT(st.otpw_count, DEC); - else if (st.flag_otpw) SERIAL_CHAR('F'); + SERIAL_CHAR(':'); SERIAL_PRINT(pwm_scale, DEC); + #if ENABLED(TMC_DEBUG) + #if HAS_TMCX1X0 || HAS_DRIVER(TMC2208) + SERIAL_CHAR('/'); SERIAL_PRINT(data.cs_actual, DEC); + #endif + #if HAS_STALLGUARD + SERIAL_CHAR('/'); + if (data.sg_result_reasonable) + SERIAL_ECHO(data.sg_result); + else + SERIAL_CHAR('-'); + #endif + #endif + SERIAL_CHAR('|'); + if (st.error_count) SERIAL_CHAR('E'); // Error + if (data.is_ot) SERIAL_CHAR('O'); // Over-temperature + if (data.is_otpw) SERIAL_CHAR('W'); // over-temperature pre-Warning + #if ENABLED(TMC_DEBUG) + if (data.is_stall) SERIAL_CHAR('G'); // stallGuard + if (data.is_stealth) SERIAL_CHAR('T'); // stealthChop + if (data.is_standstill) SERIAL_CHAR('I'); // standstIll + #endif + if (st.flag_otpw) SERIAL_CHAR('F'); // otpw Flag + SERIAL_CHAR('|'); + if (st.otpw_count > 0) SERIAL_PRINT(st.otpw_count, DEC); SERIAL_CHAR('\t'); } template - void monitor_tmc_driver(TMC &st) { + void monitor_tmc_driver(TMC &st, const bool need_update_error_counters, const bool need_debug_reporting) { TMC_driver_data data = get_driver_data(st); - if ((data.drv_status == 0xFFFFFFFF) || (data.drv_status == 0x0)) return; + if (data.drv_status == 0xFFFFFFFF || data.drv_status == 0x0) return; - if (data.is_ot /* | data.s2ga | data.s2gb*/) st.error_count++; - else if (st.error_count > 0) st.error_count--; + if (need_update_error_counters) { + if (data.is_ot /* | data.s2ga | data.s2gb*/) st.error_count++; + else if (st.error_count > 0) st.error_count--; - #if ENABLED(STOP_ON_ERROR) - if (st.error_count >= 10) { - SERIAL_EOL(); - st.printLabel(); - report_driver_error(data); - } - #endif - - // Report if a warning was triggered - if (data.is_otpw && st.otpw_count == 0) { - report_driver_otpw(st); - } - #if CURRENT_STEP_DOWN > 0 - // Decrease current if is_otpw is true and driver is enabled and there's been more than 4 warnings - if (data.is_otpw && st.otpw_count > 4) { - uint16_t I_rms = st.getMilliamps(); - if (st.isEnabled() && I_rms > 100) { - st.rms_current(I_rms - (CURRENT_STEP_DOWN)); - #if ENABLED(REPORT_CURRENT_CHANGE) - st.printLabel(); - SERIAL_ECHOLNPAIR(" current decreased to ", st.getMilliamps()); - #endif + #if ENABLED(STOP_ON_ERROR) + if (st.error_count >= 10) { + SERIAL_EOL(); + st.printLabel(); + report_driver_error(data); } - } - #endif + #endif - if (data.is_otpw) { - st.otpw_count++; - st.flag_otpw = true; + // Report if a warning was triggered + if (data.is_otpw && st.otpw_count == 0) + report_driver_otpw(st); + + #if CURRENT_STEP_DOWN > 0 + // Decrease current if is_otpw is true and driver is enabled and there's been more than 4 warnings + if (data.is_otpw && st.otpw_count > 4) { + uint16_t I_rms = st.getMilliamps(); + if (st.isEnabled() && I_rms > 100) { + st.rms_current(I_rms - (CURRENT_STEP_DOWN)); + #if ENABLED(REPORT_CURRENT_CHANGE) + st.printLabel(); + SERIAL_ECHOLNPAIR(" current decreased to ", st.getMilliamps()); + #endif + } + } + #endif + + if (data.is_otpw) { + st.otpw_count++; + st.flag_otpw = true; + } + else if (st.otpw_count > 0) st.otpw_count = 0; } - else if (st.otpw_count > 0) st.otpw_count = 0; #if ENABLED(TMC_DEBUG) - if (report_tmc_status) { + if (need_debug_reporting) report_polled_driver_data(st, data); - } #endif } @@ -225,50 +315,60 @@ void monitor_tmc_driver() { static millis_t next_poll = 0; const millis_t ms = millis(); - if (ELAPSED(ms, next_poll)) { - next_poll = ms + 500; + bool need_update_error_counters = ELAPSED(ms, next_poll); + bool need_debug_reporting = false; + if (need_update_error_counters) + next_poll = ms + MONITOR_DRIVER_STATUS_INTERVAL_MS; + #if ENABLED(TMC_DEBUG) + static millis_t next_debug_reporting = 0; + if (report_tmc_status_interval && ELAPSED(ms, next_debug_reporting)) { + need_debug_reporting = true; + next_debug_reporting = ms + report_tmc_status_interval; + } + #endif + if (need_update_error_counters || need_debug_reporting) { #if HAS_HW_COMMS(X) - monitor_tmc_driver(stepperX); + monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(Y) - monitor_tmc_driver(stepperY); + monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(Z) - monitor_tmc_driver(stepperZ); + monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(X2) - monitor_tmc_driver(stepperX2); + monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(Y2) - monitor_tmc_driver(stepperY2); + monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(Z2) - monitor_tmc_driver(stepperZ2); + monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(Z3) - monitor_tmc_driver(stepperZ3); + monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(E0) - monitor_tmc_driver(stepperE0); + monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(E1) - monitor_tmc_driver(stepperE1); + monitor_tmc_driver(stepperE1, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(E2) - monitor_tmc_driver(stepperE2); + monitor_tmc_driver(stepperE2, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(E3) - monitor_tmc_driver(stepperE3); + monitor_tmc_driver(stepperE3, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(E4) - monitor_tmc_driver(stepperE4); + monitor_tmc_driver(stepperE4, need_update_error_counters, need_debug_reporting); #endif #if HAS_HW_COMMS(E5) - monitor_tmc_driver(stepperE5); + monitor_tmc_driver(stepperE5, need_update_error_counters, need_debug_reporting); #endif #if ENABLED(TMC_DEBUG) - if (report_tmc_status) SERIAL_EOL(); + if (need_debug_reporting) SERIAL_EOL(); #endif } } @@ -278,12 +378,20 @@ #if ENABLED(TMC_DEBUG) /** - * M122 S[1,0] Enable periodic status reports + * M122 [S<0|1>] [Pnnn] Enable periodic status reports */ #if ENABLED(MONITOR_DRIVER_STATUS) - void tmc_set_report_status(const bool status) { - if ((report_tmc_status = status)) - SERIAL_ECHOLNPGM("axis:pwm_scale |status_response|"); + void tmc_set_report_interval(const uint16_t update_interval) { + if ((report_tmc_status_interval = update_interval)) + SERIAL_ECHOLNPGM("axis:pwm_scale" + #if HAS_STEALTHCHOP + "/current_scale" + #endif + #if HAS_STALLGUARD + "/mech_load" + #endif + "|flags|warncount" + ); } #endif @@ -360,7 +468,7 @@ template static void print_vsense(TMC &st) { serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); } - #if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) + #if HAS_TMCX1X0 static void tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) { switch (i) { case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break; @@ -702,7 +810,7 @@ TMC_REPORT("Stallguard thrs", TMC_SGT); DRV_REPORT("DRVSTATUS", TMC_DRV_CODES); - #if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) + #if HAS_TMCX1X0 DRV_REPORT("stallguard\t", TMC_STALLGUARD); DRV_REPORT("sg_result\t", TMC_SG_RESULT); DRV_REPORT("fsactive\t", TMC_FSACTIVE); @@ -728,7 +836,7 @@ #define PRINT_TMC_REGISTER(REG_CASE) case TMC_GET_##REG_CASE: print_hex_long(st.REG_CASE(), ':'); break - #if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) + #if HAS_TMCX1X0 static void tmc_get_ic_registers(TMC2130Stepper &st, const TMC_get_registers_enum i) { switch (i) { PRINT_TMC_REGISTER(TCOOLTHRS); diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 44ed033e7..81ef2e06a 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -53,6 +53,10 @@ #define CHOPPER_PRUSAMK3_24V { 4, 1, 4 } #define CHOPPER_MARLIN_119 { 5, 2, 3 } +#if ENABLED(MONITOR_DRIVER_STATUS) && !defined(MONITOR_DRIVER_STATUS_INTERVAL_MS) + #define MONITOR_DRIVER_STATUS_INTERVAL_MS 500u +#endif + constexpr uint16_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) { return 12650000UL * msteps / (256 * thrs * spmm); } @@ -258,7 +262,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z #if ENABLED(TMC_DEBUG) #if ENABLED(MONITOR_DRIVER_STATUS) - void tmc_set_report_status(const bool status); + void tmc_set_report_interval(const uint16_t update_interval); #endif void tmc_report_all(const bool print_x, const bool print_y, const bool print_z, const bool print_e); void tmc_get_registers(const bool print_x, const bool print_y, const bool print_z, const bool print_e); diff --git a/Marlin/src/gcode/feature/L6470/M122.cpp b/Marlin/src/gcode/feature/L6470/M122.cpp index fb6f778ce..8f806cbd9 100644 --- a/Marlin/src/gcode/feature/L6470/M122.cpp +++ b/Marlin/src/gcode/feature/L6470/M122.cpp @@ -65,7 +65,7 @@ void GcodeSuite::M122() { #define L6470_SAY_STATUS(Q) L6470_status_decode(stepper##Q.getStatus(), Q) //if (parser.seen('S')) - // tmc_set_report_status(parser.value_bool()); + // tmc_set_report_interval(parser.value_bool()); //else #if AXIS_DRIVER_TYPE_X(L6470) diff --git a/Marlin/src/gcode/feature/trinamic/M122.cpp b/Marlin/src/gcode/feature/trinamic/M122.cpp index bb46f98a9..3333e5bd3 100644 --- a/Marlin/src/gcode/feature/trinamic/M122.cpp +++ b/Marlin/src/gcode/feature/trinamic/M122.cpp @@ -39,8 +39,9 @@ void GcodeSuite::M122() { #if ENABLED(TMC_DEBUG) #if ENABLED(MONITOR_DRIVER_STATUS) - if (parser.seen('S')) - tmc_set_report_status(parser.value_bool()); + const bool sflag = parser.seen('S'), s0 = sflag && !parser.value_bool(); + if (sflag) tmc_set_report_interval(s0 ? 0 : MONITOR_DRIVER_STATUS_INTERVAL_MS); + if (!s0 && parser.seenval('P')) tmc_set_report_interval(MIN(parser.value_ushort(), MONITOR_DRIVER_STATUS_INTERVAL_MS)); #endif if (parser.seen('V')) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index a5f7bc277..4b0a85994 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -662,7 +662,7 @@ void GcodeSuite::process_parsed_command( #endif #if HAS_TRINAMIC - case 122: M122(); break; + case 122: M122(); break; // M122: Report driver configuration and status case 906: M906(); break; // M906: Set motor current in milliamps using axis codes X, Y, Z, E #if HAS_STEALTHCHOP case 569: M569(); break; // M569: Enable stealthChop on an axis. diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 4543c3e9f..666d3e7db 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -853,9 +853,10 @@ // Trinamic Stepper Drivers #if HAS_TRINAMIC - #define TMC_HAS_SPI (HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC2660) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160)) - #define HAS_STALLGUARD (HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC2660) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160)) - #define HAS_STEALTHCHOP (HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160)) + #define HAS_TMCX1X0 (HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160)) + #define TMC_HAS_SPI (HAS_TMCX1X0 || HAS_DRIVER(TMC2660)) + #define HAS_STALLGUARD (HAS_TMCX1X0 || HAS_DRIVER(TMC2660)) + #define HAS_STEALTHCHOP (HAS_TMCX1X0 || HAS_DRIVER(TMC2208)) #define AXIS_HAS_SPI(ST) (AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2160) || AXIS_DRIVER_TYPE(ST, TMC2660)) #define AXIS_HAS_STALLGUARD(ST) (AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2160) || AXIS_DRIVER_TYPE(ST, TMC2660) || AXIS_DRIVER_TYPE(ST, TMC5130) || AXIS_DRIVER_TYPE(ST, TMC5160)) #define AXIS_HAS_STEALTHCHOP(ST) (AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2160) || AXIS_DRIVER_TYPE(ST, TMC2208) || AXIS_DRIVER_TYPE(ST, TMC5130) || AXIS_DRIVER_TYPE(ST, TMC5160)) diff --git a/Marlin/src/module/stepper_indirection.cpp b/Marlin/src/module/stepper_indirection.cpp index 741489499..2e25b11af 100644 --- a/Marlin/src/module/stepper_indirection.cpp +++ b/Marlin/src/module/stepper_indirection.cpp @@ -662,6 +662,10 @@ st.microsteps(microsteps); st.intpol(INTERPOLATE); st.diss2g(true); // Disable short to ground protection. Too many false readings? + + #if ENABLED(TMC_DEBUG) + st.rdsel(0b01); + #endif } #endif // TMC2660