|
@@ -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);
|
|
@@ -564,7 +567,7 @@ void Stepper::isr() {
|
564
|
567
|
* 10µs = 160 or 200 cycles.
|
565
|
568
|
*/
|
566
|
569
|
#if EXTRA_CYCLES_XYZE > 20
|
567
|
|
- hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM);
|
|
570
|
+ hal_timer_t pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
|
568
|
571
|
#endif
|
569
|
572
|
|
570
|
573
|
#if HAS_X_STEP
|
|
@@ -596,8 +599,8 @@ void Stepper::isr() {
|
596
|
599
|
|
597
|
600
|
// For minimum pulse time wait before stopping pulses
|
598
|
601
|
#if EXTRA_CYCLES_XYZE > 20
|
599
|
|
- while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
|
600
|
|
- pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM);
|
|
602
|
+ while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
|
603
|
+ pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
|
601
|
604
|
#elif EXTRA_CYCLES_XYZE > 0
|
602
|
605
|
DELAY_NOPS(EXTRA_CYCLES_XYZE);
|
603
|
606
|
#endif
|
|
@@ -637,7 +640,7 @@ void Stepper::isr() {
|
637
|
640
|
|
638
|
641
|
// For minimum pulse time wait after stopping pulses also
|
639
|
642
|
#if EXTRA_CYCLES_XYZE > 20
|
640
|
|
- if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
|
|
643
|
+ if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
641
|
644
|
#elif EXTRA_CYCLES_XYZE > 0
|
642
|
645
|
if (i) DELAY_NOPS(EXTRA_CYCLES_XYZE);
|
643
|
646
|
#endif
|
|
@@ -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);
|
|
@@ -818,7 +827,7 @@ void Stepper::isr() {
|
818
|
827
|
for (uint8_t i = step_loops; i--;) {
|
819
|
828
|
|
820
|
829
|
#if EXTRA_CYCLES_E > 20
|
821
|
|
- hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM);
|
|
830
|
+ hal_timer_t pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
|
822
|
831
|
#endif
|
823
|
832
|
|
824
|
833
|
START_E_PULSE(0);
|
|
@@ -837,8 +846,8 @@ void Stepper::isr() {
|
837
|
846
|
|
838
|
847
|
// For minimum pulse time wait before stopping pulses
|
839
|
848
|
#if EXTRA_CYCLES_E > 20
|
840
|
|
- while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
|
841
|
|
- pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM);
|
|
849
|
+ while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
|
850
|
+ pulse_start = HAL_timer_get_current_count(PULSE_TIMER_NUM);
|
842
|
851
|
#elif EXTRA_CYCLES_E > 0
|
843
|
852
|
DELAY_NOPS(EXTRA_CYCLES_E);
|
844
|
853
|
#endif
|
|
@@ -859,7 +868,7 @@ void Stepper::isr() {
|
859
|
868
|
|
860
|
869
|
// For minimum pulse time wait before looping
|
861
|
870
|
#if EXTRA_CYCLES_E > 20
|
862
|
|
- if (i) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
|
|
871
|
+ if (i) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_current_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
863
|
872
|
#elif EXTRA_CYCLES_E > 0
|
864
|
873
|
if (i) DELAY_NOPS(EXTRA_CYCLES_E);
|
865
|
874
|
#endif
|
|
@@ -1299,7 +1308,7 @@ void Stepper::report_positions() {
|
1299
|
1308
|
|
1300
|
1309
|
#if EXTRA_CYCLES_BABYSTEP > 20
|
1301
|
1310
|
#define _SAVE_START const hal_timer_t pulse_start = HAL_timer_get_current_count(STEP_TIMER_NUM)
|
1302
|
|
- #define _PULSE_WAIT while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (STEPPER_TIMER_PRESCALE)) { /* nada */ }
|
|
1311
|
+ #define _PULSE_WAIT while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_current_count(STEP_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
1303
|
1312
|
#else
|
1304
|
1313
|
#define _SAVE_START NOOP
|
1305
|
1314
|
#if EXTRA_CYCLES_BABYSTEP > 0
|