Add some commentary to stepper ISR
This commit is contained in:
parent
d9bcc7bb45
commit
4ec3d1ea58
@ -450,10 +450,12 @@ void Stepper::isr() {
|
|||||||
#define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
|
#define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
|
||||||
#define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
|
#define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
|
||||||
|
|
||||||
|
// Advance the Bresenham counter; start a pulse if the axis needs a step
|
||||||
#define PULSE_START(AXIS) \
|
#define PULSE_START(AXIS) \
|
||||||
_COUNTER(AXIS) += current_block->steps[_AXIS(AXIS)]; \
|
_COUNTER(AXIS) += current_block->steps[_AXIS(AXIS)]; \
|
||||||
if (_COUNTER(AXIS) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
|
if (_COUNTER(AXIS) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
|
||||||
|
|
||||||
|
// Stop an active pulse, reset the Bresenham counter, update the position
|
||||||
#define PULSE_STOP(AXIS) \
|
#define PULSE_STOP(AXIS) \
|
||||||
if (_COUNTER(AXIS) > 0) { \
|
if (_COUNTER(AXIS) > 0) { \
|
||||||
_COUNTER(AXIS) -= current_block->step_event_count; \
|
_COUNTER(AXIS) -= current_block->step_event_count; \
|
||||||
@ -461,6 +463,7 @@ void Stepper::isr() {
|
|||||||
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
|
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a minimum pulse time was specified get the CPU clock
|
||||||
#if MINIMUM_STEPPER_PULSE > 0
|
#if MINIMUM_STEPPER_PULSE > 0
|
||||||
static uint32_t pulse_start;
|
static uint32_t pulse_start;
|
||||||
pulse_start = TCNT0;
|
pulse_start = TCNT0;
|
||||||
@ -476,6 +479,7 @@ void Stepper::isr() {
|
|||||||
PULSE_START(Z);
|
PULSE_START(Z);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// For non-advance use linear interpolation for E also
|
||||||
#if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
|
#if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
|
||||||
#if ENABLED(MIXING_EXTRUDER)
|
#if ENABLED(MIXING_EXTRUDER)
|
||||||
// Keep updating the single E axis
|
// Keep updating the single E axis
|
||||||
@ -492,6 +496,7 @@ void Stepper::isr() {
|
|||||||
#endif
|
#endif
|
||||||
#endif // !ADVANCE && !LIN_ADVANCE
|
#endif // !ADVANCE && !LIN_ADVANCE
|
||||||
|
|
||||||
|
// For a minimum pulse time wait before stopping pulses
|
||||||
#if MINIMUM_STEPPER_PULSE > 0
|
#if MINIMUM_STEPPER_PULSE > 0
|
||||||
#define CYCLES_EATEN_BY_CODE 10
|
#define CYCLES_EATEN_BY_CODE 10
|
||||||
while ((uint32_t)(TCNT0 - pulse_start) < (MINIMUM_STEPPER_PULSE * (F_CPU / 1000000UL)) - CYCLES_EATEN_BY_CODE) { /* nada */ }
|
while ((uint32_t)(TCNT0 - pulse_start) < (MINIMUM_STEPPER_PULSE * (F_CPU / 1000000UL)) - CYCLES_EATEN_BY_CODE) { /* nada */ }
|
||||||
@ -532,7 +537,7 @@ void Stepper::isr() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
||||||
// If we have esteps to execute, fire the next ISR "now"
|
// If we have esteps to execute, fire the next advance_isr "now"
|
||||||
if (e_steps[TOOL_E_INDEX]) OCR0A = TCNT0 + 2;
|
if (e_steps[TOOL_E_INDEX]) OCR0A = TCNT0 + 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user