|
|
@ -408,10 +408,13 @@ void Stepper::isr() { |
|
|
|
} |
|
|
|
|
|
|
|
// If there is no current block, attempt to pop one from the buffer
|
|
|
|
bool first_step = false; |
|
|
|
if (!current_block) { |
|
|
|
// Anything in the buffer?
|
|
|
|
if ((current_block = planner.get_current_block())) { |
|
|
|
trapezoid_generator_reset(); |
|
|
|
HAL_timer_set_current_count(STEP_TIMER_NUM, 0); |
|
|
|
first_step = true; |
|
|
|
|
|
|
|
// Initialize Bresenham counters to 1/2 the ceiling
|
|
|
|
counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1); |
|
|
@ -564,7 +567,7 @@ void Stepper::isr() { |
|
|
|
* 10µs = 160 or 200 cycles. |
|
|
|
*/ |
|
|
|
#if EXTRA_CYCLES_XYZE > 20 |
|
|
|
hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM); |
|
|
|
hal_timer_t pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if HAS_X_STEP |
|
|
@ -596,8 +599,8 @@ void Stepper::isr() { |
|
|
|
|
|
|
|
// For minimum pulse time wait before stopping pulses
|
|
|
|
#if EXTRA_CYCLES_XYZE > 20 |
|
|
|
while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM); |
|
|
|
while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM); |
|
|
|
#elif EXTRA_CYCLES_XYZE > 0 |
|
|
|
DELAY_NOPS(EXTRA_CYCLES_XYZE); |
|
|
|
#endif |
|
|
@ -637,7 +640,7 @@ void Stepper::isr() { |
|
|
|
|
|
|
|
// For minimum pulse time wait after stopping pulses also
|
|
|
|
#if EXTRA_CYCLES_XYZE > 20 |
|
|
|
if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
#elif EXTRA_CYCLES_XYZE > 0 |
|
|
|
if (i) DELAY_NOPS(EXTRA_CYCLES_XYZE); |
|
|
|
#endif |
|
|
@ -666,12 +669,18 @@ void Stepper::isr() { |
|
|
|
// Calculate new timer value
|
|
|
|
if (step_events_completed <= (uint32_t)current_block->accelerate_until) { |
|
|
|
|
|
|
|
if (first_step) { |
|
|
|
acc_step_rate = current_block->initial_rate; |
|
|
|
acceleration_time = 0; |
|
|
|
} |
|
|
|
else { |
|
|
|
#ifdef CPU_32_BIT |
|
|
|
MultiU32X24toH32(acc_step_rate, acceleration_time, current_block->acceleration_rate); |
|
|
|
#else |
|
|
|
MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate); |
|
|
|
#endif |
|
|
|
acc_step_rate += current_block->initial_rate; |
|
|
|
} |
|
|
|
|
|
|
|
// upper limit
|
|
|
|
NOMORE(acc_step_rate, current_block->nominal_rate); |
|
|
@ -818,7 +827,7 @@ void Stepper::isr() { |
|
|
|
for (uint8_t i = step_loops; i--;) { |
|
|
|
|
|
|
|
#if EXTRA_CYCLES_E > 20 |
|
|
|
hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM); |
|
|
|
hal_timer_t pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM); |
|
|
|
#endif |
|
|
|
|
|
|
|
START_E_PULSE(0); |
|
|
@ -837,8 +846,8 @@ void Stepper::isr() { |
|
|
|
|
|
|
|
// For minimum pulse time wait before stopping pulses
|
|
|
|
#if EXTRA_CYCLES_E > 20 |
|
|
|
while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM); |
|
|
|
while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM); |
|
|
|
#elif EXTRA_CYCLES_E > 0 |
|
|
|
DELAY_NOPS(EXTRA_CYCLES_E); |
|
|
|
#endif |
|
|
@ -859,7 +868,7 @@ void Stepper::isr() { |
|
|
|
|
|
|
|
// For minimum pulse time wait before looping
|
|
|
|
#if EXTRA_CYCLES_E > 20 |
|
|
|
if (i) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
if (i) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
#elif EXTRA_CYCLES_E > 0 |
|
|
|
if (i) DELAY_NOPS(EXTRA_CYCLES_E); |
|
|
|
#endif |
|
|
@ -1299,7 +1308,7 @@ void Stepper::report_positions() { |
|
|
|
|
|
|
|
#if EXTRA_CYCLES_BABYSTEP > 20 |
|
|
|
#define _SAVE_START const hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM) |
|
|
|
#define _PULSE_WAIT while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
#define _PULSE_WAIT while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } |
|
|
|
#else |
|
|
|
#define _SAVE_START NOOP |
|
|
|
#if EXTRA_CYCLES_BABYSTEP > 0 |
|
|
|