소스 검색

Merge pull request #8736 from thinkyhead/bf2_first_step_fix

[2.0.x] Reset timer count before first block step
Scott Lahteine 7 년 전
부모
커밋
11f9c253e0
No account linked to committer's email address

+ 22
- 13
Marlin/src/HAL/HAL_AVR/HAL_AVR.h 파일 보기

100
 
100
 
101
 
101
 
102
 // timers
102
 // timers
103
-#define STEP_TIMER_NUM OCR1A
104
-#define TEMP_TIMER_NUM 0
105
-#define TEMP_TIMER_FREQUENCY (F_CPU / 64.0 / 256.0)
106
-
107
 #define HAL_TIMER_RATE          ((F_CPU) / 8)    // i.e., 2MHz or 2.5MHz
103
 #define HAL_TIMER_RATE          ((F_CPU) / 8)    // i.e., 2MHz or 2.5MHz
108
-#define HAL_STEPPER_TIMER_RATE  HAL_TIMER_RATE
109
-#define STEPPER_TIMER_PRESCALE  INT0_PRESCALER
110
 #define HAL_TICKS_PER_US        ((HAL_STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double
104
 #define HAL_TICKS_PER_US        ((HAL_STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double
111
 
105
 
106
+#define TEMP_TIMER_FREQUENCY    ((F_CPU) / 64.0 / 256.0)
107
+
108
+#define HAL_STEPPER_TIMER_RATE  HAL_TIMER_RATE
109
+#define STEPPER_TIMER_PRESCALE  8
110
+
111
+#define STEP_TIMER_NUM          1
112
+#define TIMER_OCR_1             OCR1A
113
+#define TIMER_COUNTER_1         TCNT1
114
+
115
+#define TEMP_TIMER_NUM          0
116
+#define TIMER_OCR_0             OCR0A
117
+#define TIMER_COUNTER_0         TCNT0
118
+
119
+#define PULSE_TIMER_NUM         TEMP_TIMER_NUM
120
+#define PULSE_TIMER_PRESCALE    8
121
+
112
 #define ENABLE_STEPPER_DRIVER_INTERRUPT()  SBI(TIMSK1, OCIE1A)
122
 #define ENABLE_STEPPER_DRIVER_INTERRUPT()  SBI(TIMSK1, OCIE1A)
113
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() CBI(TIMSK1, OCIE1A)
123
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() CBI(TIMSK1, OCIE1A)
114
 
124
 
115
 #define ENABLE_TEMPERATURE_INTERRUPT()  SBI(TIMSK0, OCIE0B)
125
 #define ENABLE_TEMPERATURE_INTERRUPT()  SBI(TIMSK0, OCIE0B)
116
 #define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B)
126
 #define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B)
117
 
127
 
118
-//void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
119
-#define HAL_timer_start(timer_num,frequency)
120
-
121
-//void HAL_timer_set_count(const uint8_t timer_num, const uint16_t count);
122
-#define HAL_timer_set_count(timer, count) timer = (count)
128
+#define HAL_timer_start(timer_num, frequency)
123
 
129
 
124
-#define HAL_timer_get_current_count(timer) timer
130
+#define _CAT(a, ...) a ## __VA_ARGS__
131
+#define HAL_timer_set_count(timer, count) (_CAT(TIMER_OCR_, timer) = count)
132
+#define HAL_timer_get_count(timer) _CAT(TIMER_OCR_, timer)
133
+#define HAL_timer_set_current_count(timer, count) (_CAT(TIMER_COUNTER_, timer) = count)
134
+#define HAL_timer_get_current_count(timer) _CAT(TIMER_COUNTER_, timer)
125
 
135
 
126
-//void HAL_timer_isr_prologue(const uint8_t timer_num);
127
 #define HAL_timer_isr_prologue(timer_num)
136
 #define HAL_timer_isr_prologue(timer_num)
128
 
137
 
129
 #define HAL_STEP_TIMER_ISR ISR(TIMER1_COMPA_vect)
138
 #define HAL_STEP_TIMER_ISR ISR(TIMER1_COMPA_vect)

+ 10
- 2
Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h 파일 보기

64
 #define HAL_STEP_TIMER_ISR  void TC3_Handler()
64
 #define HAL_STEP_TIMER_ISR  void TC3_Handler()
65
 #define HAL_TEMP_TIMER_ISR  void TC4_Handler()
65
 #define HAL_TEMP_TIMER_ISR  void TC4_Handler()
66
 
66
 
67
+#define PULSE_TIMER_NUM STEP_TIMER_NUM
68
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
69
+
67
 // --------------------------------------------------------------------------
70
 // --------------------------------------------------------------------------
68
 // Types
71
 // Types
69
 // --------------------------------------------------------------------------
72
 // --------------------------------------------------------------------------
87
 
90
 
88
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
91
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
89
 
92
 
90
-FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const uint32_t count) {
93
+FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
91
   const tTimerConfig *pConfig = &TimerConfig[timer_num];
94
   const tTimerConfig *pConfig = &TimerConfig[timer_num];
92
   pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count;
95
   pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count;
93
 }
96
 }
97
   return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
100
   return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
98
 }
101
 }
99
 
102
 
100
-FORCE_INLINE static uint32_t HAL_timer_get_current_count(const uint8_t timer_num) {
103
+FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
104
+  const tTimerConfig *pConfig = &TimerConfig[timer_num];
105
+  pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV = count;
106
+}
107
+
108
+FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
101
   const tTimerConfig *pConfig = &TimerConfig[timer_num];
109
   const tTimerConfig *pConfig = &TimerConfig[timer_num];
102
   return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
110
   return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
103
 }
111
 }

+ 10
- 0
Marlin/src/HAL/HAL_LPC1768/HAL_timers.h 파일 보기

53
 #define HAL_TEMP_TIMER_RATE    1000000
53
 #define HAL_TEMP_TIMER_RATE    1000000
54
 #define TEMP_TIMER_FREQUENCY   1000 // temperature interrupt frequency
54
 #define TEMP_TIMER_FREQUENCY   1000 // temperature interrupt frequency
55
 
55
 
56
+#define PULSE_TIMER_NUM STEP_TIMER_NUM
57
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
58
+
56
 #define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
59
 #define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
57
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
60
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
58
 #define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
61
 #define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
100
   return 0;
103
   return 0;
101
 }
104
 }
102
 
105
 
106
+FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
107
+  switch (timer_num) {
108
+    case 0: LPC_TIM0->TC = count; break;
109
+    case 1: LPC_TIM1->TC = count; break;
110
+  }
111
+}
112
+
103
 FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
113
 FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
104
   switch (timer_num) {
114
   switch (timer_num) {
105
     case 0: return LPC_TIM0->TC;
115
     case 0: return LPC_TIM0->TC;

+ 26
- 18
Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h 파일 보기

51
 #define TEMP_TIMER_NUM 2  // index of timer to use for temperature
51
 #define TEMP_TIMER_NUM 2  // index of timer to use for temperature
52
 #define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
52
 #define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
53
 
53
 
54
-
55
 #define HAL_TIMER_RATE         (F_CPU)  // frequency of timers peripherals
54
 #define HAL_TIMER_RATE         (F_CPU)  // frequency of timers peripherals
56
 #define STEPPER_TIMER_PRESCALE 36             // prescaler for setting stepper timer, 2Mhz
55
 #define STEPPER_TIMER_PRESCALE 36             // prescaler for setting stepper timer, 2Mhz
57
 #define HAL_STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)   // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
56
 #define HAL_STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)   // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
58
 #define HAL_TICKS_PER_US       ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per us
57
 #define HAL_TICKS_PER_US       ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per us
59
 
58
 
59
+#define PULSE_TIMER_NUM STEP_TIMER_NUM
60
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
61
+
60
 #define TEMP_TIMER_PRESCALE     1000 // prescaler for setting Temp timer, 72Khz
62
 #define TEMP_TIMER_PRESCALE     1000 // prescaler for setting Temp timer, 72Khz
61
 #define TEMP_TIMER_FREQUENCY    1000 // temperature interrupt frequency
63
 #define TEMP_TIMER_FREQUENCY    1000 // temperature interrupt frequency
62
 
64
 
63
-#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt (STEP_TIMER_NUM)
64
-#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt (STEP_TIMER_NUM)
65
+#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
66
+#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
65
 
67
 
66
-#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt (TEMP_TIMER_NUM)
67
-#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt (TEMP_TIMER_NUM)
68
+#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
69
+#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
68
 
70
 
69
 #define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
71
 #define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
70
 // TODO change this
72
 // TODO change this
92
 // Public functions
94
 // Public functions
93
 // --------------------------------------------------------------------------
95
 // --------------------------------------------------------------------------
94
 
96
 
95
-void HAL_timer_start (uint8_t timer_num, uint32_t frequency);
97
+void HAL_timer_start(uint8_t timer_num, uint32_t frequency);
96
 void HAL_timer_enable_interrupt(uint8_t timer_num);
98
 void HAL_timer_enable_interrupt(uint8_t timer_num);
97
 void HAL_timer_disable_interrupt(uint8_t timer_num);
99
 void HAL_timer_disable_interrupt(uint8_t timer_num);
98
 
100
 
107
  * Todo: Look at that possibility later.
109
  * Todo: Look at that possibility later.
108
  */
110
  */
109
 
111
 
110
-FORCE_INLINE static void HAL_timer_set_count (uint8_t timer_num, uint32_t count) {
112
+FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
111
   switch (timer_num) {
113
   switch (timer_num) {
112
   case STEP_TIMER_NUM:
114
   case STEP_TIMER_NUM:
113
     StepperTimer.pause();
115
     StepperTimer.pause();
114
-    StepperTimer.setCompare (STEP_TIMER_CHAN, count);
115
-    StepperTimer.refresh ();
116
-    StepperTimer.resume ();
116
+    StepperTimer.setCompare(STEP_TIMER_CHAN, count);
117
+    StepperTimer.refresh();
118
+    StepperTimer.resume();
117
     break;
119
     break;
118
   case TEMP_TIMER_NUM:
120
   case TEMP_TIMER_NUM:
119
     TempTimer.pause();
121
     TempTimer.pause();
120
-    TempTimer.setCompare (TEMP_TIMER_CHAN, count);
121
-    TempTimer.refresh ();
122
-    TempTimer.resume ();
122
+    TempTimer.setCompare(TEMP_TIMER_CHAN, count);
123
+    TempTimer.refresh();
124
+    TempTimer.resume();
123
     break;
125
     break;
124
   default:
126
   default:
125
     break;
127
     break;
126
   }
128
   }
127
 }
129
 }
128
 
130
 
129
-FORCE_INLINE static hal_timer_t HAL_timer_get_count (uint8_t timer_num) {
131
+FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
130
   hal_timer_t temp;
132
   hal_timer_t temp;
131
   switch (timer_num) {
133
   switch (timer_num) {
132
   case STEP_TIMER_NUM:
134
   case STEP_TIMER_NUM:
142
   return temp;
144
   return temp;
143
 }
145
 }
144
 
146
 
145
-FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(uint8_t timer_num) {
147
+FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
148
+  switch (timer_num) {
149
+    case STEP_TIMER_NUM: StepperTimer.setCount(count); break;
150
+    case TEMP_TIMER_NUM: TempTimer.setCount(count); break;
151
+  }
152
+}
153
+
154
+FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
146
   hal_timer_t temp;
155
   hal_timer_t temp;
147
   switch (timer_num) {
156
   switch (timer_num) {
148
   case STEP_TIMER_NUM:
157
   case STEP_TIMER_NUM:
158
   return temp;
167
   return temp;
159
 }
168
 }
160
 
169
 
170
+//void HAL_timer_isr_prologue (const uint8_t timer_num);
161
 
171
 
162
-//void HAL_timer_isr_prologue (uint8_t timer_num);
163
-
164
-FORCE_INLINE static void HAL_timer_isr_prologue(uint8_t timer_num) {
172
+FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
165
   switch (timer_num) {
173
   switch (timer_num) {
166
   case STEP_TIMER_NUM:
174
   case STEP_TIMER_NUM:
167
     StepperTimer.pause();
175
     StepperTimer.pause();

+ 15
- 5
Marlin/src/HAL/HAL_TEENSY35_36/HAL_timers_Teensy.h 파일 보기

57
 #define STEPPER_TIMER STEP_TIMER_NUM // Alias?
57
 #define STEPPER_TIMER STEP_TIMER_NUM // Alias?
58
 #define STEPPER_TIMER_PRESCALE 0 // Not defined anywhere else!
58
 #define STEPPER_TIMER_PRESCALE 0 // Not defined anywhere else!
59
 
59
 
60
+#define PULSE_TIMER_NUM STEP_TIMER_NUM
61
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
62
+
60
 #define HAL_TIMER_RATE         (FTM0_TIMER_RATE)
63
 #define HAL_TIMER_RATE         (FTM0_TIMER_RATE)
61
 #define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE
64
 #define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE
62
 #define HAL_TICKS_PER_US       ((HAL_STEPPER_TIMER_RATE) / 1000000)
65
 #define HAL_TICKS_PER_US       ((HAL_STEPPER_TIMER_RATE) / 1000000)
75
 
78
 
76
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
79
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
77
 
80
 
78
-FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const uint32_t count) {
79
-  switch(timer_num) {
81
+FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
82
+  switch (timer_num) {
80
     case 0: FTM0_C0V = count; break;
83
     case 0: FTM0_C0V = count; break;
81
     case 1: FTM1_C0V = count; break;
84
     case 1: FTM1_C0V = count; break;
82
   }
85
   }
83
 }
86
 }
84
 
87
 
85
 FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
88
 FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
86
-  switch(timer_num) {
89
+  switch (timer_num) {
87
     case 0: return FTM0_C0V;
90
     case 0: return FTM0_C0V;
88
     case 1: return FTM1_C0V;
91
     case 1: return FTM1_C0V;
89
   }
92
   }
90
   return 0;
93
   return 0;
91
 }
94
 }
92
 
95
 
93
-FORCE_INLINE static uint32_t HAL_timer_get_current_count(const uint8_t timer_num) {
94
-  switch(timer_num) {
96
+FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
97
+  switch (timer_num) {
98
+    case 0: FTM0_CNT = count;
99
+    case 1: FTM1_CNT = count;
100
+  }
101
+}
102
+
103
+FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
104
+  switch (timer_num) {
95
     case 0: return FTM0_CNT;
105
     case 0: return FTM0_CNT;
96
     case 1: return FTM1_CNT;
106
     case 1: return FTM1_CNT;
97
   }
107
   }

+ 1
- 2
Marlin/src/core/macros.h 파일 보기

44
 #define _O3          __attribute__((optimize("O3")))
44
 #define _O3          __attribute__((optimize("O3")))
45
 
45
 
46
 // Clock speed factors
46
 // Clock speed factors
47
-#define CYCLES_PER_MICROSECOND (F_CPU / 1000000L) // 16 or 20
48
-#define INT0_PRESCALER 8
47
+#define CYCLES_PER_MICROSECOND (F_CPU / 1000000L) // 16 or 20 on AVR
49
 
48
 
50
 // Highly granular delays for step pulses, etc.
49
 // Highly granular delays for step pulses, etc.
51
 #define DELAY_0_NOP NOOP
50
 #define DELAY_0_NOP NOOP

+ 24
- 15
Marlin/src/module/stepper.cpp 파일 보기

408
   }
408
   }
409
 
409
 
410
   // If there is no current block, attempt to pop one from the buffer
410
   // If there is no current block, attempt to pop one from the buffer
411
+  bool first_step = false;
411
   if (!current_block) {
412
   if (!current_block) {
412
     // Anything in the buffer?
413
     // Anything in the buffer?
413
     if ((current_block = planner.get_current_block())) {
414
     if ((current_block = planner.get_current_block())) {
414
       trapezoid_generator_reset();
415
       trapezoid_generator_reset();
416
+      HAL_timer_set_current_count(STEP_TIMER_NUM, 0);
417
+      first_step = true;
415
 
418
 
416
       // Initialize Bresenham counters to 1/2 the ceiling
419
       // Initialize Bresenham counters to 1/2 the ceiling
417
       counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1);
420
       counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1);
564
      * 10µs = 160 or 200 cycles.
567
      * 10µs = 160 or 200 cycles.
565
      */
568
      */
566
     #if EXTRA_CYCLES_XYZE > 20
569
     #if EXTRA_CYCLES_XYZE > 20
567
-      hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM);
570
+      hal_timer_t pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
568
     #endif
571
     #endif
569
 
572
 
570
     #if HAS_X_STEP
573
     #if HAS_X_STEP
596
 
599
 
597
     // For minimum pulse time wait before stopping pulses
600
     // For minimum pulse time wait before stopping pulses
598
     #if EXTRA_CYCLES_XYZE > 20
601
     #if EXTRA_CYCLES_XYZE > 20
599
-      while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
600
-      pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM);
602
+      while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
603
+      pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
601
     #elif EXTRA_CYCLES_XYZE > 0
604
     #elif EXTRA_CYCLES_XYZE > 0
602
       DELAY_NOPS(EXTRA_CYCLES_XYZE);
605
       DELAY_NOPS(EXTRA_CYCLES_XYZE);
603
     #endif
606
     #endif
637
 
640
 
638
     // For minimum pulse time wait after stopping pulses also
641
     // For minimum pulse time wait after stopping pulses also
639
     #if EXTRA_CYCLES_XYZE > 20
642
     #if EXTRA_CYCLES_XYZE > 20
640
-      if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
643
+      if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
641
     #elif EXTRA_CYCLES_XYZE > 0
644
     #elif EXTRA_CYCLES_XYZE > 0
642
       if (i) DELAY_NOPS(EXTRA_CYCLES_XYZE);
645
       if (i) DELAY_NOPS(EXTRA_CYCLES_XYZE);
643
     #endif
646
     #endif
666
   // Calculate new timer value
669
   // Calculate new timer value
667
   if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
670
   if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
668
 
671
 
669
-    #ifdef CPU_32_BIT
670
-      MultiU32X24toH32(acc_step_rate, acceleration_time, current_block->acceleration_rate);
671
-    #else
672
-      MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
673
-    #endif
674
-    acc_step_rate += current_block->initial_rate;
672
+    if (first_step) {
673
+      acc_step_rate = current_block->initial_rate;
674
+      acceleration_time = 0;
675
+    }
676
+    else {
677
+      #ifdef CPU_32_BIT
678
+        MultiU32X24toH32(acc_step_rate, acceleration_time, current_block->acceleration_rate);
679
+      #else
680
+        MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
681
+      #endif
682
+      acc_step_rate += current_block->initial_rate;
683
+    }
675
 
684
 
676
     // upper limit
685
     // upper limit
677
     NOMORE(acc_step_rate, current_block->nominal_rate);
686
     NOMORE(acc_step_rate, current_block->nominal_rate);
818
     for (uint8_t i = step_loops; i--;) {
827
     for (uint8_t i = step_loops; i--;) {
819
 
828
 
820
       #if EXTRA_CYCLES_E > 20
829
       #if EXTRA_CYCLES_E > 20
821
-        hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM);
830
+        hal_timer_t pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
822
       #endif
831
       #endif
823
 
832
 
824
       START_E_PULSE(0);
833
       START_E_PULSE(0);
837
 
846
 
838
       // For minimum pulse time wait before stopping pulses
847
       // For minimum pulse time wait before stopping pulses
839
       #if EXTRA_CYCLES_E > 20
848
       #if EXTRA_CYCLES_E > 20
840
-        while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
841
-        pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM);
849
+        while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
850
+        pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
842
       #elif EXTRA_CYCLES_E > 0
851
       #elif EXTRA_CYCLES_E > 0
843
         DELAY_NOPS(EXTRA_CYCLES_E);
852
         DELAY_NOPS(EXTRA_CYCLES_E);
844
       #endif
853
       #endif
859
 
868
 
860
       // For minimum pulse time wait before looping
869
       // For minimum pulse time wait before looping
861
       #if EXTRA_CYCLES_E > 20
870
       #if EXTRA_CYCLES_E > 20
862
-        if (i) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
871
+        if (i) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
863
       #elif EXTRA_CYCLES_E > 0
872
       #elif EXTRA_CYCLES_E > 0
864
         if (i) DELAY_NOPS(EXTRA_CYCLES_E);
873
         if (i) DELAY_NOPS(EXTRA_CYCLES_E);
865
       #endif
874
       #endif
1299
 
1308
 
1300
   #if EXTRA_CYCLES_BABYSTEP > 20
1309
   #if EXTRA_CYCLES_BABYSTEP > 20
1301
     #define _SAVE_START const hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM)
1310
     #define _SAVE_START const hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM)
1302
-    #define _PULSE_WAIT while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
1311
+    #define _PULSE_WAIT while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
1303
   #else
1312
   #else
1304
     #define _SAVE_START NOOP
1313
     #define _SAVE_START NOOP
1305
     #if EXTRA_CYCLES_BABYSTEP > 0
1314
     #if EXTRA_CYCLES_BABYSTEP > 0

+ 0
- 3
Marlin/src/module/stepper.h 파일 보기

362
       OCR1A_nominal = calc_timer_interval(current_block->nominal_rate);
362
       OCR1A_nominal = calc_timer_interval(current_block->nominal_rate);
363
       // make a note of the number of step loops required at nominal speed
363
       // make a note of the number of step loops required at nominal speed
364
       step_loops_nominal = step_loops;
364
       step_loops_nominal = step_loops;
365
-      acc_step_rate = current_block->initial_rate;
366
-      acceleration_time = calc_timer_interval(acc_step_rate);
367
-      _NEXT_ISR(acceleration_time);
368
 
365
 
369
       #if ENABLED(LIN_ADVANCE)
366
       #if ENABLED(LIN_ADVANCE)
370
         if (current_block->use_advance_lead) {
367
         if (current_block->use_advance_lead) {

Loading…
취소
저장