|
@@ -408,10 +408,13 @@ void Stepper::isr() {
|
408
|
408
|
}
|
409
|
409
|
|
410
|
410
|
// If there is no current block, attempt to pop one from the buffer
|
|
411
|
+ bool first_step = false;
|
411
|
412
|
if (!current_block) {
|
412
|
413
|
// Anything in the buffer?
|
413
|
414
|
if ((current_block = planner.get_current_block())) {
|
414
|
415
|
trapezoid_generator_reset();
|
|
416
|
+ HAL_timer_set_current_count(STEP_TIMER_NUM, 0);
|
|
417
|
+ first_step = true;
|
415
|
418
|
|
416
|
419
|
// Initialize Bresenham counters to 1/2 the ceiling
|
417
|
420
|
counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1);
|
|
@@ -666,12 +669,18 @@ void Stepper::isr() {
|
666
|
669
|
// Calculate new timer value
|
667
|
670
|
if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
|
668
|
671
|
|
669
|
|
- #ifdef CPU_32_BIT
|
670
|
|
- MultiU32X24toH32(acc_step_rate, acceleration_time, current_block->acceleration_rate);
|
671
|
|
- #else
|
672
|
|
- MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
|
673
|
|
- #endif
|
674
|
|
- acc_step_rate += current_block->initial_rate;
|
|
672
|
+ if (first_step) {
|
|
673
|
+ acc_step_rate = current_block->initial_rate;
|
|
674
|
+ acceleration_time = 0;
|
|
675
|
+ }
|
|
676
|
+ else {
|
|
677
|
+ #ifdef CPU_32_BIT
|
|
678
|
+ MultiU32X24toH32(acc_step_rate, acceleration_time, current_block->acceleration_rate);
|
|
679
|
+ #else
|
|
680
|
+ MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
|
|
681
|
+ #endif
|
|
682
|
+ acc_step_rate += current_block->initial_rate;
|
|
683
|
+ }
|
675
|
684
|
|
676
|
685
|
// upper limit
|
677
|
686
|
NOMORE(acc_step_rate, current_block->nominal_rate);
|