|
@@ -803,9 +803,9 @@ void Stepper::isr() {
|
803
|
803
|
#if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
|
804
|
804
|
#ifdef CPU_32_BIT
|
805
|
805
|
// Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
|
806
|
|
- uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM);
|
807
|
|
- uint32_t stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
|
808
|
|
- HAL_timer_set_count(STEP_TIMER_NUM, stepper_timer_count < stepper_timer_current_count ? stepper_timer_current_count : stepper_timer_count);
|
|
806
|
+ uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
|
|
807
|
+ stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
|
|
808
|
+ HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
|
809
|
809
|
#else
|
810
|
810
|
NOLESS(OCR1A, TCNT1 + 16);
|
811
|
811
|
#endif
|
|
@@ -932,7 +932,7 @@ void Stepper::isr() {
|
932
|
932
|
// Is the next advance ISR scheduled before the next main ISR?
|
933
|
933
|
if (nextAdvanceISR <= nextMainISR) {
|
934
|
934
|
// Set up the next interrupt
|
935
|
|
- OCR1A = nextAdvanceISR;
|
|
935
|
+ HAL_timer_set_count(STEP_TIMER_NUM, nextAdvanceISR);
|
936
|
936
|
// New interval for the next main ISR
|
937
|
937
|
if (nextMainISR) nextMainISR -= nextAdvanceISR;
|
938
|
938
|
// Will call Stepper::advance_isr on the next interrupt
|
|
@@ -940,7 +940,7 @@ void Stepper::isr() {
|
940
|
940
|
}
|
941
|
941
|
else {
|
942
|
942
|
// The next main ISR comes first
|
943
|
|
- OCR1A = nextMainISR;
|
|
943
|
+ HAL_timer_set_count(STEP_TIMER_NUM, nextMainISR);
|
944
|
944
|
// New interval for the next advance ISR, if any
|
945
|
945
|
if (nextAdvanceISR && nextAdvanceISR != ADV_NEVER)
|
946
|
946
|
nextAdvanceISR -= nextMainISR;
|
|
@@ -949,7 +949,14 @@ void Stepper::isr() {
|
949
|
949
|
}
|
950
|
950
|
|
951
|
951
|
// Don't run the ISR faster than possible
|
952
|
|
- NOLESS(OCR1A, TCNT1 + 16);
|
|
952
|
+ #ifdef CPU_32_BIT
|
|
953
|
+ // Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
|
|
954
|
+ uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
|
|
955
|
+ stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
|
|
956
|
+ HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
|
|
957
|
+ #else
|
|
958
|
+ NOLESS(OCR1A, TCNT1 + 16);
|
|
959
|
+ #endif
|
953
|
960
|
|
954
|
961
|
// Restore original ISR settings
|
955
|
962
|
HAL_ENABLE_ISRs();
|