Reset timer count before first block step
This commit is contained in:
parent
6149b82119
commit
5cf6a062e3
@ -408,10 +408,13 @@ void Stepper::isr() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If there is no current block, attempt to pop one from the buffer
|
// If there is no current block, attempt to pop one from the buffer
|
||||||
|
bool first_step = false;
|
||||||
if (!current_block) {
|
if (!current_block) {
|
||||||
// Anything in the buffer?
|
// Anything in the buffer?
|
||||||
if ((current_block = planner.get_current_block())) {
|
if ((current_block = planner.get_current_block())) {
|
||||||
trapezoid_generator_reset();
|
trapezoid_generator_reset();
|
||||||
|
HAL_timer_set_current_count(STEP_TIMER_NUM, 0);
|
||||||
|
first_step = true;
|
||||||
|
|
||||||
// Initialize Bresenham counters to 1/2 the ceiling
|
// Initialize Bresenham counters to 1/2 the ceiling
|
||||||
counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1);
|
counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1);
|
||||||
@ -666,12 +669,18 @@ void Stepper::isr() {
|
|||||||
// Calculate new timer value
|
// Calculate new timer value
|
||||||
if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
|
if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
|
||||||
|
|
||||||
#ifdef CPU_32_BIT
|
if (first_step) {
|
||||||
MultiU32X24toH32(acc_step_rate, acceleration_time, current_block->acceleration_rate);
|
acc_step_rate = current_block->initial_rate;
|
||||||
#else
|
acceleration_time = 0;
|
||||||
MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
|
}
|
||||||
#endif
|
else {
|
||||||
acc_step_rate += current_block->initial_rate;
|
#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
|
// upper limit
|
||||||
NOMORE(acc_step_rate, current_block->nominal_rate);
|
NOMORE(acc_step_rate, current_block->nominal_rate);
|
||||||
|
@ -362,9 +362,6 @@ class Stepper {
|
|||||||
OCR1A_nominal = calc_timer_interval(current_block->nominal_rate);
|
OCR1A_nominal = calc_timer_interval(current_block->nominal_rate);
|
||||||
// make a note of the number of step loops required at nominal speed
|
// make a note of the number of step loops required at nominal speed
|
||||||
step_loops_nominal = step_loops;
|
step_loops_nominal = step_loops;
|
||||||
acc_step_rate = current_block->initial_rate;
|
|
||||||
acceleration_time = calc_timer_interval(acc_step_rate);
|
|
||||||
_NEXT_ISR(acceleration_time);
|
|
||||||
|
|
||||||
#if ENABLED(LIN_ADVANCE)
|
#if ENABLED(LIN_ADVANCE)
|
||||||
if (current_block->use_advance_lead) {
|
if (current_block->use_advance_lead) {
|
||||||
|
Loading…
Reference in New Issue
Block a user