Browse Source

Add some commentary to stepper ISR

Scott Lahteine 9 years ago
parent
commit
4ec3d1ea58
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      Marlin/stepper.cpp

+ 6
- 1
Marlin/stepper.cpp View File

450
       #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
450
       #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
451
       #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
451
       #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
452
 
452
 
453
+      // Advance the Bresenham counter; start a pulse if the axis needs a step
453
       #define PULSE_START(AXIS) \
454
       #define PULSE_START(AXIS) \
454
         _COUNTER(AXIS) += current_block->steps[_AXIS(AXIS)]; \
455
         _COUNTER(AXIS) += current_block->steps[_AXIS(AXIS)]; \
455
         if (_COUNTER(AXIS) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
456
         if (_COUNTER(AXIS) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
456
 
457
 
458
+      // Stop an active pulse, reset the Bresenham counter, update the position
457
       #define PULSE_STOP(AXIS) \
459
       #define PULSE_STOP(AXIS) \
458
         if (_COUNTER(AXIS) > 0) { \
460
         if (_COUNTER(AXIS) > 0) { \
459
           _COUNTER(AXIS) -= current_block->step_event_count; \
461
           _COUNTER(AXIS) -= current_block->step_event_count; \
461
           _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
463
           _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
462
         }
464
         }
463
 
465
 
466
+      // If a minimum pulse time was specified get the CPU clock
464
       #if MINIMUM_STEPPER_PULSE > 0
467
       #if MINIMUM_STEPPER_PULSE > 0
465
         static uint32_t pulse_start;
468
         static uint32_t pulse_start;
466
         pulse_start = TCNT0;
469
         pulse_start = TCNT0;
476
         PULSE_START(Z);
479
         PULSE_START(Z);
477
       #endif
480
       #endif
478
 
481
 
482
+      // For non-advance use linear interpolation for E also
479
       #if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
483
       #if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
480
         #if ENABLED(MIXING_EXTRUDER)
484
         #if ENABLED(MIXING_EXTRUDER)
481
           // Keep updating the single E axis
485
           // Keep updating the single E axis
492
         #endif
496
         #endif
493
       #endif // !ADVANCE && !LIN_ADVANCE
497
       #endif // !ADVANCE && !LIN_ADVANCE
494
 
498
 
499
+      // For a minimum pulse time wait before stopping pulses
495
       #if MINIMUM_STEPPER_PULSE > 0
500
       #if MINIMUM_STEPPER_PULSE > 0
496
         #define CYCLES_EATEN_BY_CODE 10
501
         #define CYCLES_EATEN_BY_CODE 10
497
         while ((uint32_t)(TCNT0 - pulse_start) < (MINIMUM_STEPPER_PULSE * (F_CPU / 1000000UL)) - CYCLES_EATEN_BY_CODE) { /* nada */ }
502
         while ((uint32_t)(TCNT0 - pulse_start) < (MINIMUM_STEPPER_PULSE * (F_CPU / 1000000UL)) - CYCLES_EATEN_BY_CODE) { /* nada */ }
532
     }
537
     }
533
 
538
 
534
     #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
539
     #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
535
-      // If we have esteps to execute, fire the next ISR "now"
540
+      // If we have esteps to execute, fire the next advance_isr "now"
536
       if (e_steps[TOOL_E_INDEX]) OCR0A = TCNT0 + 2;
541
       if (e_steps[TOOL_E_INDEX]) OCR0A = TCNT0 + 2;
537
     #endif
542
     #endif
538
 
543
 

Loading…
Cancel
Save