diff --git a/g2core/board/Archim/hardware.h b/g2core/board/Archim/hardware.h index 64caf475..6da17870 100644 --- a/g2core/board/Archim/hardware.h +++ b/g2core/board/Archim/hardware.h @@ -126,8 +126,7 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<3,0> dda_timer_type; // stepper pulse generation in stepper.cpp -typedef TimerChannel<4,0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef TimerChannel<4,0> load_timer_type; // request load timer in stepper.cpp typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp diff --git a/g2core/board/ArduinoDue/hardware.h b/g2core/board/ArduinoDue/hardware.h index ec8d48d5..e01e70d4 100644 --- a/g2core/board/ArduinoDue/hardware.h +++ b/g2core/board/ArduinoDue/hardware.h @@ -128,8 +128,7 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<3,0> dda_timer_type; // stepper pulse generation in stepper.cpp -typedef TimerChannel<4,0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef TimerChannel<4,0> load_timer_type; // request load timer in stepper.cpp typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp diff --git a/g2core/board/G2v9/hardware.h b/g2core/board/G2v9/hardware.h index a00fb5d6..260ed18a 100644 --- a/g2core/board/G2v9/hardware.h +++ b/g2core/board/G2v9/hardware.h @@ -128,8 +128,7 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<3,0> dda_timer_type; // stepper pulse generation in stepper.cpp -typedef TimerChannel<4,0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef TimerChannel<4,0> load_timer_type; // request load timer in stepper.cpp typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp diff --git a/g2core/board/gquadratic/hardware.h b/g2core/board/gquadratic/hardware.h index 5bf1a1fa..a28bf858 100644 --- a/g2core/board/gquadratic/hardware.h +++ b/g2core/board/gquadratic/hardware.h @@ -129,8 +129,7 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<9, 0> dda_timer_type; // stepper pulse generation in stepper.cpp -typedef TimerChannel<10, 0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef TimerChannel<10, 0> load_timer_type; // request load timer in stepper.cpp typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp diff --git a/g2core/board/gquintic/hardware.h b/g2core/board/gquintic/hardware.h index fb7f284e..e7fb56ba 100755 --- a/g2core/board/gquintic/hardware.h +++ b/g2core/board/gquintic/hardware.h @@ -127,8 +127,7 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<9, 0> dda_timer_type; // stepper pulse generation in stepper.cpp -typedef TimerChannel<10, 0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef TimerChannel<10, 0> load_timer_type; // request load timer in stepper.cpp typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp diff --git a/g2core/board/printrboardg2/hardware.h b/g2core/board/printrboardg2/hardware.h index 6046c789..244a2681 100755 --- a/g2core/board/printrboardg2/hardware.h +++ b/g2core/board/printrboardg2/hardware.h @@ -126,8 +126,7 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<3,0> dda_timer_type; // stepper pulse generation in stepper.cpp -typedef TimerChannel<4,0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef TimerChannel<4,0> load_timer_type; // request load timer in stepper.cpp typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp diff --git a/g2core/board/sbv300/hardware.h b/g2core/board/sbv300/hardware.h index 0e576ab4..5ded07eb 100755 --- a/g2core/board/sbv300/hardware.h +++ b/g2core/board/sbv300/hardware.h @@ -126,8 +126,7 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<3,0> dda_timer_type; // stepper pulse generation in stepper.cpp -typedef TimerChannel<4,0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef TimerChannel<4,0> load_timer_type; // request load timer in stepper.cpp typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp diff --git a/g2core/stepper.cpp b/g2core/stepper.cpp index 4c3be1f8..bb765422 100644 --- a/g2core/stepper.cpp +++ b/g2core/stepper.cpp @@ -76,7 +76,6 @@ extern OutputPin debug_pin3; //extern OutputPin debug_pin4; dda_timer_type dda_timer {kTimerUpToMatch, FREQUENCY_DDA}; // stepper pulse generation -dwell_timer_type dwell_timer {kTimerUpToMatch, FREQUENCY_DWELL}; // dwell timer load_timer_type load_timer; // triggers load of next stepper segment exec_timer_type exec_timer; // triggers calculation of next+1 stepper segment fwd_plan_timer_type fwd_plan_timer; // triggers planning of next block @@ -117,9 +116,6 @@ void stepper_init() // If you need more pulse width you need to drop the DDA clock rate dda_timer.setInterrupts(kInterruptOnOverflow | kInterruptPriorityHighest); - // setup DWELL timer - dwell_timer.setInterrupts(kInterruptOnOverflow | kInterruptPriorityHighest); - // setup software interrupt load timer load_timer.setInterrupts(kInterruptOnSoftwareTrigger | kInterruptPriorityHigh); @@ -148,7 +144,6 @@ void stepper_init() void stepper_reset() { dda_timer.stop(); // stop all movement - dwell_timer.stop(); st_run.dda_ticks_downcount = 0; // signal the runtime is not busy st_pre.buffer_state = PREP_BUFFER_OWNED_BY_EXEC; // set to EXEC or it won't restart @@ -339,22 +334,6 @@ void dda_timer_type::interrupt() } // MOTATE_TIMER_INTERRUPT } // namespace Motate -/***** Dwell Interrupt Service Routine ************************************************** - * ISR - DDA timer interrupt routine - service ticks from DDA timer - */ - -namespace Motate { // Must define timer interrupts inside the Motate namespace - template<> - void dwell_timer_type::interrupt() - { - dwell_timer.getInterruptCause(); // read SR to clear interrupt condition - if (--st_run.dda_ticks_downcount == 0) { - dwell_timer.stop(); - _load_move(); - } - } -} // namespace Motate - /**************************************************************************************** * Exec sequencing code - computes and prepares next load segment * st_request_exec_move() - SW interrupt to request to execute a move @@ -635,8 +614,24 @@ static void _load_move() // handle dwells } else if (st_pre.block_type == BLOCK_TYPE_DWELL) { st_run.dda_ticks_downcount = st_pre.dda_ticks; - dda_timer.stop(); // ++++ This is a stopgap. The DDA timer should have been stopped before here - dwell_timer.start(); + st_run.mot[MOTOR_1].substep_accumulator = 0; + st_run.mot[MOTOR_2].substep_accumulator = 0; +#if (MOTORS > 2) + st_run.mot[MOTOR_3].substep_accumulator = 0; +#endif +#if (MOTORS > 3) + st_run.mot[MOTOR_4].substep_accumulator = 0; +#endif +#if (MOTORS > 4) + st_run.mot[MOTOR_5].substep_accumulator = 0; +#endif +#if (MOTORS > 5) + st_run.mot[MOTOR_6].substep_accumulator = 0; +#endif + + //**** do this last **** + // Note: we are using the dda timer for the dwells (we didn't always) + dda_timer.start(); // start the DDA timer if not already running // handle synchronous commands } else if (st_pre.block_type == BLOCK_TYPE_COMMAND) { @@ -787,7 +782,8 @@ void st_prep_command(void *bf) void st_prep_dwell(float microseconds) { st_pre.block_type = BLOCK_TYPE_DWELL; - st_pre.dda_ticks = (uint32_t)((microseconds/1000000) * FREQUENCY_DWELL); + // Note: we are using the dda timer for the dwells (we didn't always) + st_pre.dda_ticks = (uint32_t)((microseconds/1000000) * FREQUENCY_DDA); st_pre.buffer_state = PREP_BUFFER_OWNED_BY_LOADER; // signal that prep buffer is ready }