|
@@ -323,8 +323,13 @@ void Stepper::isr() {
|
323
|
323
|
|
324
|
324
|
HAL_TIMER_TYPE ocr_val;
|
325
|
325
|
|
326
|
|
- #define ENDSTOP_NOMINAL_OCR_VAL 3000 // check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
|
327
|
|
- #define OCR_VAL_TOLERANCE 1000 // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
|
|
326
|
+ #if defined(CPU_32_BIT)
|
|
327
|
+ #define ENDSTOP_NOMINAL_OCR_VAL 1500 * HAL_TICKS_PER_US // check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
|
|
328
|
+ #define OCR_VAL_TOLERANCE 500 * HAL_TICKS_PER_US // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
|
|
329
|
+ #else
|
|
330
|
+ #define ENDSTOP_NOMINAL_OCR_VAL 3000 // check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
|
|
331
|
+ #define OCR_VAL_TOLERANCE 1000 // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
|
|
332
|
+ #endif
|
328
|
333
|
|
329
|
334
|
#if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
|
330
|
335
|
// Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars)
|
|
@@ -335,40 +340,45 @@ void Stepper::isr() {
|
335
|
340
|
#endif
|
336
|
341
|
#endif
|
337
|
342
|
|
338
|
|
- #define _SPLIT(L) (ocr_val = (HAL_TIMER_TYPE)L)
|
339
|
|
- #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE) || defined(CPU_32_BIT)
|
340
|
|
- #define SPLIT(L) _SPLIT(L)
|
341
|
|
- #else // sample endstops in between step pulses
|
342
|
|
- static uint32_t step_remaining = 0;
|
343
|
|
- #define SPLIT(L) do { \
|
344
|
|
- _SPLIT(L); \
|
345
|
|
- if (ENDSTOPS_ENABLED && L > ENDSTOP_NOMINAL_OCR_VAL) { \
|
346
|
|
- const uint16_t remainder = (uint16_t)L % (ENDSTOP_NOMINAL_OCR_VAL); \
|
347
|
|
- ocr_val = (remainder < OCR_VAL_TOLERANCE) ? ENDSTOP_NOMINAL_OCR_VAL + remainder : ENDSTOP_NOMINAL_OCR_VAL; \
|
348
|
|
- step_remaining = (uint16_t)L - ocr_val; \
|
349
|
|
- } \
|
350
|
|
- }while(0)
|
|
343
|
+ static uint32_t step_remaining = 0; // SPLIT function always runs. This allows 16 bit timers to be
|
|
344
|
+ // used to generate the stepper ISR.
|
|
345
|
+ #define SPLIT(L) do { \
|
|
346
|
+ if (L > ENDSTOP_NOMINAL_OCR_VAL) { \
|
|
347
|
+ const uint32_t remainder = (uint32_t)L % (ENDSTOP_NOMINAL_OCR_VAL); \
|
|
348
|
+ ocr_val = (remainder < OCR_VAL_TOLERANCE) ? ENDSTOP_NOMINAL_OCR_VAL + remainder : ENDSTOP_NOMINAL_OCR_VAL; \
|
|
349
|
+ step_remaining = (uint32_t)L - ocr_val; \
|
|
350
|
+ } \
|
|
351
|
+ else \
|
|
352
|
+ ocr_val = L;\
|
|
353
|
+ }while(0)
|
351
|
354
|
|
352
|
|
- if (step_remaining && ENDSTOPS_ENABLED) { // Just check endstops - not yet time for a step
|
|
355
|
+ if (step_remaining) {
|
|
356
|
+ if (ENDSTOPS_ENABLED)
|
353
|
357
|
endstops.update();
|
354
|
|
- if (step_remaining > ENDSTOP_NOMINAL_OCR_VAL) {
|
355
|
|
- step_remaining -= ENDSTOP_NOMINAL_OCR_VAL;
|
356
|
|
- ocr_val = ENDSTOP_NOMINAL_OCR_VAL;
|
357
|
|
- }
|
358
|
|
- else {
|
359
|
|
- ocr_val = step_remaining;
|
360
|
|
- step_remaining = 0; // last one before the ISR that does the step
|
361
|
|
- }
|
|
358
|
+ if (step_remaining > ENDSTOP_NOMINAL_OCR_VAL) {
|
|
359
|
+ step_remaining -= ENDSTOP_NOMINAL_OCR_VAL;
|
|
360
|
+ ocr_val = ENDSTOP_NOMINAL_OCR_VAL;
|
|
361
|
+ }
|
|
362
|
+ else {
|
|
363
|
+ ocr_val = step_remaining;
|
|
364
|
+ step_remaining = 0; // last one before the ISR that does the step
|
|
365
|
+ }
|
362
|
366
|
|
363
|
|
- _NEXT_ISR(ocr_val);
|
|
367
|
+ _NEXT_ISR(ocr_val);
|
364
|
368
|
|
|
369
|
+ #if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
|
|
370
|
+ #ifdef CPU_32_BIT
|
|
371
|
+ HAL_timer_set_count(STEP_TIMER_NUM, ocr_val);
|
|
372
|
+ #else
|
365
|
373
|
NOLESS(OCR1A, TCNT1 + 16);
|
366
|
|
-
|
367
|
|
- HAL_ENABLE_ISRs(); // re-enable ISRs
|
368
|
|
- return;
|
369
|
|
- }
|
|
374
|
+ #endif
|
|
375
|
+ HAL_ENABLE_ISRs(); // re-enable ISRs
|
370
|
376
|
#endif
|
371
|
377
|
|
|
378
|
+ return;
|
|
379
|
+ }
|
|
380
|
+
|
|
381
|
+
|
372
|
382
|
if (cleaning_buffer_counter) {
|
373
|
383
|
--cleaning_buffer_counter;
|
374
|
384
|
current_block = NULL;
|
|
@@ -748,7 +758,6 @@ void Stepper::isr() {
|
748
|
758
|
|
749
|
759
|
SPLIT(timer); // split step into multiple ISRs if larger than ENDSTOP_NOMINAL_OCR_VAL
|
750
|
760
|
_NEXT_ISR(ocr_val);
|
751
|
|
-
|
752
|
761
|
deceleration_time += timer;
|
753
|
762
|
|
754
|
763
|
#if ENABLED(LIN_ADVANCE)
|
|
@@ -832,7 +841,6 @@ void Stepper::isr() {
|
832
|
841
|
// Timer interrupt for E. e_steps is set in the main routine;
|
833
|
842
|
|
834
|
843
|
void Stepper::advance_isr() {
|
835
|
|
-
|
836
|
844
|
nextAdvanceISR = eISR_Rate;
|
837
|
845
|
|
838
|
846
|
#if ENABLED(MK2_MULTIPLEXER)
|