Bläddra i källkod

Add missing dedge init for TMC2209 (#14370)

teemuatlut 6 år sedan
förälder
incheckning
2247bf1ba5
1 ändrade filer med 11 tillägg och 25 borttagningar
  1. 11
    25
      Marlin/src/module/stepper_indirection.cpp

+ 11
- 25
Marlin/src/module/stepper_indirection.cpp Visa fil

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) {
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
     st.begin();
270
     st.begin();
271
 
271
 
272
-    static constexpr int8_t timings[] = CHOPPER_TIMING; // Default 4, -2, 1
273
-
274
     CHOPCONF_t chopconf{0};
272
     CHOPCONF_t chopconf{0};
275
     chopconf.tbl = 1;
273
     chopconf.tbl = 1;
276
-    chopconf.toff = timings[0];
274
+    chopconf.toff = chopper_timing.toff;
277
     chopconf.intpol = INTERPOLATE;
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
     #if ENABLED(SQUARE_WAVE_STEPPING)
278
     #if ENABLED(SQUARE_WAVE_STEPPING)
281
       chopconf.dedge = true;
279
       chopconf.dedge = true;
282
     #endif
280
     #endif
286
     st.microsteps(microsteps);
284
     st.microsteps(microsteps);
287
     st.iholddelay(10);
285
     st.iholddelay(10);
288
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
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
     st.en_pwm_mode(stealth);
288
     st.en_pwm_mode(stealth);
289
+    st.stored.stealthChop_enabled = stealth;
299
 
290
 
300
     TMC2160_n::PWMCONF_t pwmconf{0};
291
     TMC2160_n::PWMCONF_t pwmconf{0};
301
     pwmconf.pwm_lim = 12;
292
     pwmconf.pwm_lim = 12;
573
     chopconf.intpol = INTERPOLATE;
564
     chopconf.intpol = INTERPOLATE;
574
     chopconf.hend = chopper_timing.hend + 3;
565
     chopconf.hend = chopper_timing.hend + 3;
575
     chopconf.hstrt = chopper_timing.hstrt - 1;
566
     chopconf.hstrt = chopper_timing.hstrt - 1;
567
+    #if ENABLED(SQUARE_WAVE_STEPPING)
568
+      chopconf.dedge = true;
569
+    #endif
576
     st.CHOPCONF(chopconf.sr);
570
     st.CHOPCONF(chopconf.sr);
577
 
571
 
578
     st.rms_current(mA, HOLD_MULTIPLIER);
572
     st.rms_current(mA, HOLD_MULTIPLIER);
673
   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) {
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
     st.begin();
668
     st.begin();
675
 
669
 
676
-    int8_t timings[] = CHOPPER_TIMING; // Default 4, -2, 1
677
-
678
     CHOPCONF_t chopconf{0};
670
     CHOPCONF_t chopconf{0};
679
     chopconf.tbl = 1;
671
     chopconf.tbl = 1;
680
-    chopconf.toff = timings[0];
672
+    chopconf.toff = chopper_timing.toff;
681
     chopconf.intpol = INTERPOLATE;
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
     #if ENABLED(SQUARE_WAVE_STEPPING)
676
     #if ENABLED(SQUARE_WAVE_STEPPING)
685
       chopconf.dedge = true;
677
       chopconf.dedge = true;
686
     #endif
678
     #endif
691
     st.iholddelay(10);
683
     st.iholddelay(10);
692
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
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
     st.en_pwm_mode(stealth);
686
     st.en_pwm_mode(stealth);
687
+    st.stored.stealthChop_enabled = stealth;
702
 
688
 
703
     TMC2160_n::PWMCONF_t pwmconf{0};
689
     TMC2160_n::PWMCONF_t pwmconf{0};
704
     pwmconf.pwm_lim = 12;
690
     pwmconf.pwm_lim = 12;

Laddar…
Avbryt
Spara