Browse Source

Add missing dedge init for TMC2209 (#14370)

teemuatlut 5 years ago
parent
commit
2247bf1ba5
1 changed files with 11 additions and 25 deletions
  1. 11
    25
      Marlin/src/module/stepper_indirection.cpp

+ 11
- 25
Marlin/src/module/stepper_indirection.cpp View File

@@ -269,14 +269,12 @@
269 269
   void tmc_init(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const bool stealth) {
270 270
     st.begin();
271 271
 
272
-    static constexpr int8_t timings[] = CHOPPER_TIMING; // Default 4, -2, 1
273
-
274 272
     CHOPCONF_t chopconf{0};
275 273
     chopconf.tbl = 1;
276
-    chopconf.toff = timings[0];
274
+    chopconf.toff = chopper_timing.toff;
277 275
     chopconf.intpol = INTERPOLATE;
278
-    chopconf.hend = timings[1] + 3;
279
-    chopconf.hstrt = timings[2] - 1;
276
+    chopconf.hend = chopper_timing.hend + 3;
277
+    chopconf.hstrt = chopper_timing.hstrt - 1;
280 278
     #if ENABLED(SQUARE_WAVE_STEPPING)
281 279
       chopconf.dedge = true;
282 280
     #endif
@@ -286,16 +284,9 @@
286 284
     st.microsteps(microsteps);
287 285
     st.iholddelay(10);
288 286
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
289
-    st.TCOOLTHRS(0xFFFFF);
290
-
291
-    #if ENABLED(ADAPTIVE_CURRENT)
292
-      COOLCONF_t coolconf{0};
293
-      coolconf.semin = INCREASE_CURRENT_THRS;
294
-      coolconf.semax = REDUCE_CURRENT_THRS;
295
-      st.COOLCONF(coolconf.sr);
296
-    #endif
297 287
 
298 288
     st.en_pwm_mode(stealth);
289
+    st.stored.stealthChop_enabled = stealth;
299 290
 
300 291
     TMC2160_n::PWMCONF_t pwmconf{0};
301 292
     pwmconf.pwm_lim = 12;
@@ -573,6 +564,9 @@
573 564
     chopconf.intpol = INTERPOLATE;
574 565
     chopconf.hend = chopper_timing.hend + 3;
575 566
     chopconf.hstrt = chopper_timing.hstrt - 1;
567
+    #if ENABLED(SQUARE_WAVE_STEPPING)
568
+      chopconf.dedge = true;
569
+    #endif
576 570
     st.CHOPCONF(chopconf.sr);
577 571
 
578 572
     st.rms_current(mA, HOLD_MULTIPLIER);
@@ -673,14 +667,12 @@
673 667
   void tmc_init(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const bool stealth) {
674 668
     st.begin();
675 669
 
676
-    int8_t timings[] = CHOPPER_TIMING; // Default 4, -2, 1
677
-
678 670
     CHOPCONF_t chopconf{0};
679 671
     chopconf.tbl = 1;
680
-    chopconf.toff = timings[0];
672
+    chopconf.toff = chopper_timing.toff;
681 673
     chopconf.intpol = INTERPOLATE;
682
-    chopconf.hend = timings[1] + 3;
683
-    chopconf.hstrt = timings[2] - 1;
674
+    chopconf.hend = chopper_timing.hend + 3;
675
+    chopconf.hstrt = chopper_timing.hstrt - 1;
684 676
     #if ENABLED(SQUARE_WAVE_STEPPING)
685 677
       chopconf.dedge = true;
686 678
     #endif
@@ -691,14 +683,8 @@
691 683
     st.iholddelay(10);
692 684
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
693 685
 
694
-    #if ENABLED(ADAPTIVE_CURRENT)
695
-      COOLCONF_t coolconf{0};
696
-      coolconf.semin = INCREASE_CURRENT_THRS;
697
-      coolconf.semax = REDUCE_CURRENT_THRS;
698
-      st.COOLCONF(coolconf.sr);
699
-    #endif
700
-
701 686
     st.en_pwm_mode(stealth);
687
+    st.stored.stealthChop_enabled = stealth;
702 688
 
703 689
     TMC2160_n::PWMCONF_t pwmconf{0};
704 690
     pwmconf.pwm_lim = 12;

Loading…
Cancel
Save