|
@@ -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
|