瀏覽代碼

[2.0.x] HAL timer set/get count => set/get compare (#9581)

To reduce confusion over the current timer count vs. the compare (aka "top") value. Caution: this re-uses the function name, changing its meaning.
Scott Lahteine 6 年之前
父節點
當前提交
03d790451f
沒有連結到貢獻者的電子郵件帳戶。

+ 4
- 4
Marlin/src/HAL/HAL_AVR/HAL_AVR.h 查看文件

@@ -147,10 +147,10 @@ extern "C" {
147 147
 #define HAL_timer_start(timer_num, frequency)
148 148
 
149 149
 #define _CAT(a, ...) a ## __VA_ARGS__
150
-#define HAL_timer_set_count(timer, count) (_CAT(TIMER_OCR_, timer) = count)
151
-#define HAL_timer_get_count(timer) _CAT(TIMER_OCR_, timer)
152
-#define HAL_timer_set_current_count(timer, count) (_CAT(TIMER_COUNTER_, timer) = count)
153
-#define HAL_timer_get_current_count(timer) _CAT(TIMER_COUNTER_, timer)
150
+#define HAL_timer_set_compare(timer, compare) (_CAT(TIMER_OCR_, timer) = compare)
151
+#define HAL_timer_get_compare(timer) _CAT(TIMER_OCR_, timer)
152
+#define HAL_timer_set_count(timer, count) (_CAT(TIMER_COUNTER_, timer) = count)
153
+#define HAL_timer_get_count(timer) _CAT(TIMER_COUNTER_, timer)
154 154
 
155 155
 #define HAL_timer_isr_prologue(timer_num)
156 156
 

+ 2
- 2
Marlin/src/HAL/HAL_DUE/HAL_timers_Due.cpp 查看文件

@@ -127,9 +127,9 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
127 127
 }
128 128
 
129 129
 #if 0
130
-  void HAL_timer_set_count(const uint8_t timer_num, const uint32_t count) {
130
+  void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare) {
131 131
     const tTimerConfig * const pConfig = &TimerConfig[timer_num];
132
-    TC_SetRC(pConfig->pTimerRegs, pConfig->channel, count);
132
+    TC_SetRC(pConfig->pTimerRegs, pConfig->channel, compare);
133 133
   }
134 134
 
135 135
   void HAL_timer_isr_prologue(const uint8_t timer_num) {

+ 5
- 5
Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h 查看文件

@@ -91,22 +91,22 @@ extern const tTimerConfig TimerConfig[];
91 91
 
92 92
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
93 93
 
94
-FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
94
+FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
95 95
   const tTimerConfig * const pConfig = &TimerConfig[timer_num];
96
-  pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count;
96
+  pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = compare;
97 97
 }
98 98
 
99
-FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
99
+FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
100 100
   const tTimerConfig * const pConfig = &TimerConfig[timer_num];
101 101
   return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
102 102
 }
103 103
 
104
-FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
104
+FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
105 105
   const tTimerConfig * const pConfig = &TimerConfig[timer_num];
106 106
   pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV = count;
107 107
 }
108 108
 
109
-FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
109
+FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
110 110
   const tTimerConfig * const pConfig = &TimerConfig[timer_num];
111 111
   return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
112 112
 }

+ 10
- 10
Marlin/src/HAL/HAL_LPC1768/HAL_timers.h 查看文件

@@ -87,22 +87,22 @@ typedef uint32_t hal_timer_t;
87 87
 void HAL_timer_init(void);
88 88
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
89 89
 
90
-FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
90
+FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
91 91
   switch (timer_num) {
92 92
     case 0:
93
-      LPC_TIM0->MR0 = count;
94
-      if (LPC_TIM0->TC > count)
95
-        LPC_TIM0->TC = count - 5; // generate an immediate stepper ISR
93
+      LPC_TIM0->MR0 = compare;
94
+      if (LPC_TIM0->TC > compare)
95
+        LPC_TIM0->TC = compare - 5; // generate an immediate stepper ISR
96 96
       break;
97 97
     case 1:
98
-      LPC_TIM1->MR0 = count;
99
-      if (LPC_TIM1->TC > count)
100
-        LPC_TIM1->TC = count - 5; // make sure we don't have one extra long period
98
+      LPC_TIM1->MR0 = compare;
99
+      if (LPC_TIM1->TC > compare)
100
+        LPC_TIM1->TC = compare - 5; // make sure we don't have one extra long period
101 101
       break;
102 102
   }
103 103
 }
104 104
 
105
-FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
105
+FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
106 106
   switch (timer_num) {
107 107
     case 0: return LPC_TIM0->MR0;
108 108
     case 1: return LPC_TIM1->MR0;
@@ -110,14 +110,14 @@ FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
110 110
   return 0;
111 111
 }
112 112
 
113
-FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
113
+FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
114 114
   switch (timer_num) {
115 115
     case 0: LPC_TIM0->TC = count; break;
116 116
     case 1: LPC_TIM1->TC = count; break;
117 117
   }
118 118
 }
119 119
 
120
-FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
120
+FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
121 121
   switch (timer_num) {
122 122
     case 0: return LPC_TIM0->TC;
123 123
     case 1: return LPC_TIM1->TC;

+ 8
- 8
Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h 查看文件

@@ -46,7 +46,7 @@
46 46
 typedef uint16_t hal_timer_t;
47 47
 #define HAL_TIMER_TYPE_MAX 0xFFFF
48 48
 
49
-#if defined MCU_STM32F103CB  || defined(MCU_STM32F103C8)
49
+#if defined(MCU_STM32F103CB) || defined(MCU_STM32F103C8)
50 50
   #define STEP_TIMER_NUM 4 // For C8/CB boards, use timer 4
51 51
 #else
52 52
   #define STEP_TIMER_NUM 5 // for other boards, five is fine.
@@ -82,8 +82,8 @@ typedef uint16_t hal_timer_t;
82 82
 #define ENABLE_TEMPERATURE_INTERRUPT() timer_enable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN)
83 83
 #define DISABLE_TEMPERATURE_INTERRUPT() timer_disable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN)
84 84
 
85
-#define HAL_timer_get_current_count(timer_num) timer_get_count(TIMER_DEV(timer_num))
86
-#define HAL_timer_set_current_count(timer_num, count) timer_set_count(TIMER_DEV(timer_num), (uint16)count)
85
+#define HAL_timer_get_count(timer_num) timer_get_count(TIMER_DEV(timer_num))
86
+#define HAL_timer_set_count(timer_num, count) timer_set_count(TIMER_DEV(timer_num), (uint16)count)
87 87
 
88 88
 
89 89
 #define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
@@ -128,21 +128,21 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
128 128
  * Todo: Look at that possibility later.
129 129
  */
130 130
 
131
-FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
132
-  //count = min(count, HAL_TIMER_TYPE_MAX);
131
+FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
132
+  //compare = min(compare, HAL_TIMER_TYPE_MAX);
133 133
   switch (timer_num) {
134 134
   case STEP_TIMER_NUM:
135
-    timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, count);
135
+    timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, compare);
136 136
     return;
137 137
   case TEMP_TIMER_NUM:
138
-    timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, count);
138
+    timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, compare);
139 139
     return;
140 140
   default:
141 141
     return;
142 142
   }
143 143
 }
144 144
 
145
-FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
145
+FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
146 146
   switch (timer_num) {
147 147
   case STEP_TIMER_NUM:
148 148
     return timer_get_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN);

+ 5
- 5
Marlin/src/HAL/HAL_STM32F7/HAL_timers_STM32F7.cpp 查看文件

@@ -117,11 +117,11 @@ extern "C" void TIM7_IRQHandler() {
117 117
   ((void(*)(void))timerConfig[1].callback)();
118 118
 }
119 119
 
120
-void HAL_timer_set_count(const uint8_t timer_num, const uint32_t count) {
121
-  __HAL_TIM_SetAutoreload(&timerConfig[timer_num].timerdef, count);
120
+void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare) {
121
+  __HAL_TIM_SetAutoreload(&timerConfig[timer_num].timerdef, compare);
122 122
 }
123 123
 
124
-void HAL_timer_set_current_count(const uint8_t timer_num, const uint32_t count) {
124
+void HAL_timer_set_count(const uint8_t timer_num, const uint32_t count) {
125 125
   __HAL_TIM_SetAutoreload(&timerConfig[timer_num].timerdef, count);
126 126
 }
127 127
 
@@ -133,11 +133,11 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
133 133
   HAL_NVIC_DisableIRQ(timerConfig[timer_num].IRQ_Id);
134 134
 }
135 135
 
136
-hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
136
+hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
137 137
   return __HAL_TIM_GetAutoreload(&timerConfig[timer_num].timerdef);
138 138
 }
139 139
 
140
-uint32_t HAL_timer_get_current_count(const uint8_t timer_num) {
140
+uint32_t HAL_timer_get_count(const uint8_t timer_num) {
141 141
   return __HAL_TIM_GetCounter(&timerConfig[timer_num].timerdef);
142 142
 }
143 143
 

+ 5
- 5
Marlin/src/HAL/HAL_STM32F7/HAL_timers_STM32F7.h 查看文件

@@ -91,12 +91,12 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
91 91
 void HAL_timer_enable_interrupt(const uint8_t timer_num);
92 92
 void HAL_timer_disable_interrupt(const uint8_t timer_num);
93 93
 
94
-void HAL_timer_set_count(const uint8_t timer_num, const uint32_t count);
95
-hal_timer_t HAL_timer_get_count(const uint8_t timer_num);
96
-uint32_t HAL_timer_get_current_count(const uint8_t timer_num);
94
+void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare);
95
+hal_timer_t HAL_timer_get_compare(const uint8_t timer_num);
96
+uint32_t HAL_timer_get_count(const uint8_t timer_num);
97 97
 
98
-void HAL_timer_set_current_count(const uint8_t timer_num, const uint32_t count); // New
99
-/*FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
98
+void HAL_timer_set_count(const uint8_t timer_num, const uint32_t count); // New
99
+/*FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
100 100
   // To do ??
101 101
 }*/
102 102
 

+ 6
- 6
Marlin/src/HAL/HAL_TEENSY35_36/HAL_timers_Teensy.h 查看文件

@@ -80,14 +80,14 @@ typedef uint32_t hal_timer_t;
80 80
 
81 81
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
82 82
 
83
-FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
83
+FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
84 84
   switch (timer_num) {
85
-    case 0: FTM0_C0V = count; break;
86
-    case 1: FTM1_C0V = count; break;
85
+    case 0: FTM0_C0V = compare; break;
86
+    case 1: FTM1_C0V = compare; break;
87 87
   }
88 88
 }
89 89
 
90
-FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
90
+FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
91 91
   switch (timer_num) {
92 92
     case 0: return FTM0_C0V;
93 93
     case 1: return FTM1_C0V;
@@ -95,14 +95,14 @@ FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
95 95
   return 0;
96 96
 }
97 97
 
98
-FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
98
+FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
99 99
   switch (timer_num) {
100 100
     case 0: FTM0_CNT = count;
101 101
     case 1: FTM1_CNT = count;
102 102
   }
103 103
 }
104 104
 
105
-FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
105
+FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
106 106
   switch (timer_num) {
107 107
     case 0: return FTM0_CNT;
108 108
     case 1: return FTM1_CNT;

+ 19
- 19
Marlin/src/module/stepper.cpp 查看文件

@@ -371,7 +371,7 @@ void Stepper::isr() {
371 371
 
372 372
     #if DISABLED(LIN_ADVANCE)
373 373
       #ifdef CPU_32_BIT
374
-        HAL_timer_set_count(STEP_TIMER_NUM, ocr_val);
374
+        HAL_timer_set_compare(STEP_TIMER_NUM, ocr_val);
375 375
       #else
376 376
         NOLESS(OCR1A, TCNT1 + 16);
377 377
       #endif
@@ -560,7 +560,7 @@ void Stepper::isr() {
560 560
      * 10µs = 160 or 200 cycles.
561 561
      */
562 562
     #if EXTRA_CYCLES_XYZE > 20
563
-      hal_timer_t pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
563
+      hal_timer_t pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM);
564 564
     #endif
565 565
 
566 566
     #if HAS_X_STEP
@@ -592,8 +592,8 @@ void Stepper::isr() {
592 592
 
593 593
     // For minimum pulse time wait before stopping pulses
594 594
     #if EXTRA_CYCLES_XYZE > 20
595
-      while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
596
-      pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
595
+      while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
596
+      pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM);
597 597
     #elif EXTRA_CYCLES_XYZE > 0
598 598
       DELAY_NOPS(EXTRA_CYCLES_XYZE);
599 599
     #endif
@@ -633,7 +633,7 @@ void Stepper::isr() {
633 633
 
634 634
     // For minimum pulse time wait after stopping pulses also
635 635
     #if EXTRA_CYCLES_XYZE > 20
636
-      if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
636
+      if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
637 637
     #elif EXTRA_CYCLES_XYZE > 0
638 638
       if (i) DELAY_NOPS(EXTRA_CYCLES_XYZE);
639 639
     #endif
@@ -750,9 +750,9 @@ void Stepper::isr() {
750 750
   #if DISABLED(LIN_ADVANCE)
751 751
     #ifdef CPU_32_BIT
752 752
       // Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
753
-      hal_timer_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
754
-                  stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
755
-      HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
753
+      hal_timer_t stepper_timer_count = HAL_timer_get_compare(STEP_TIMER_NUM),
754
+                  stepper_timer_current_count = HAL_timer_get_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
755
+      HAL_timer_set_compare(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
756 756
     #else
757 757
       NOLESS(OCR1A, TCNT1 + 16);
758 758
     #endif
@@ -814,7 +814,7 @@ void Stepper::isr() {
814 814
     for (uint8_t i = step_loops; i--;) {
815 815
 
816 816
       #if EXTRA_CYCLES_E > 20
817
-        hal_timer_t pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
817
+        hal_timer_t pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM);
818 818
       #endif
819 819
 
820 820
       START_E_PULSE(0);
@@ -833,8 +833,8 @@ void Stepper::isr() {
833 833
 
834 834
       // For minimum pulse time wait before stopping pulses
835 835
       #if EXTRA_CYCLES_E > 20
836
-        while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
837
-        pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
836
+        while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
837
+        pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM);
838 838
       #elif EXTRA_CYCLES_E > 0
839 839
         DELAY_NOPS(EXTRA_CYCLES_E);
840 840
       #endif
@@ -855,7 +855,7 @@ void Stepper::isr() {
855 855
 
856 856
       // For minimum pulse time wait before looping
857 857
       #if EXTRA_CYCLES_E > 20
858
-        if (i) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
858
+        if (i) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
859 859
       #elif EXTRA_CYCLES_E > 0
860 860
         if (i) DELAY_NOPS(EXTRA_CYCLES_E);
861 861
       #endif
@@ -878,7 +878,7 @@ void Stepper::isr() {
878 878
     // Is the next advance ISR scheduled before the next main ISR?
879 879
     if (nextAdvanceISR <= nextMainISR) {
880 880
       // Set up the next interrupt
881
-      HAL_timer_set_count(STEP_TIMER_NUM, nextAdvanceISR);
881
+      HAL_timer_set_compare(STEP_TIMER_NUM, nextAdvanceISR);
882 882
       // New interval for the next main ISR
883 883
       if (nextMainISR) nextMainISR -= nextAdvanceISR;
884 884
       // Will call Stepper::advance_isr on the next interrupt
@@ -886,7 +886,7 @@ void Stepper::isr() {
886 886
     }
887 887
     else {
888 888
       // The next main ISR comes first
889
-      HAL_timer_set_count(STEP_TIMER_NUM, nextMainISR);
889
+      HAL_timer_set_compare(STEP_TIMER_NUM, nextMainISR);
890 890
       // New interval for the next advance ISR, if any
891 891
       if (nextAdvanceISR && nextAdvanceISR != ADV_NEVER)
892 892
         nextAdvanceISR -= nextMainISR;
@@ -897,9 +897,9 @@ void Stepper::isr() {
897 897
     // Don't run the ISR faster than possible
898 898
     #ifdef CPU_32_BIT
899 899
       // Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
900
-      uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
901
-               stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
902
-      HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
900
+      uint32_t stepper_timer_count = HAL_timer_get_compare(STEP_TIMER_NUM),
901
+               stepper_timer_current_count = HAL_timer_get_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
902
+      HAL_timer_set_compare(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
903 903
     #else
904 904
       NOLESS(OCR1A, TCNT1 + 16);
905 905
     #endif
@@ -1304,8 +1304,8 @@ void Stepper::report_positions() {
1304 1304
   #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true)
1305 1305
 
1306 1306
   #if EXTRA_CYCLES_BABYSTEP > 20
1307
-    #define _SAVE_START const hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM)
1308
-    #define _PULSE_WAIT while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
1307
+    #define _SAVE_START const hal_timer_t pulse_start = HAL_timer_get_count(STEP_TIMER_NUM)
1308
+    #define _PULSE_WAIT while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_count(STEP_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
1309 1309
   #else
1310 1310
     #define _SAVE_START NOOP
1311 1311
     #if EXTRA_CYCLES_BABYSTEP > 0

+ 1
- 1
Marlin/src/module/stepper.h 查看文件

@@ -108,7 +108,7 @@ class Stepper {
108 108
                                                  // i.e., the current amount of pressure applied
109 109
                                                  // to the spring (=filament).
110 110
     #else
111
-      #define _NEXT_ISR(T) HAL_timer_set_count(STEP_TIMER_NUM, T);
111
+      #define _NEXT_ISR(T) HAL_timer_set_compare(STEP_TIMER_NUM, T);
112 112
     #endif // LIN_ADVANCE
113 113
 
114 114
     static long acceleration_time, deceleration_time;

Loading…
取消
儲存