LPC_RIT->RICTRL |= (8L); // Enable rit
}
+// Synchronise the acceleration timer with the new block
+void StepTicker::synchronize_acceleration() {
+ LPC_RIT->RICOUNTER = 0;
+}
+
+
// Call signal_move_finished() on each active motor that asked to be signaled. We do this instead of inside of tick() so that
// all tick()s are called before we do the move finishing
void StepTicker::signal_a_move_finished(){
for (int i = 0; i < num_motors; i++) {
if(this->unstep[i]){
this->motor[i]->unstep();
- this->unstep[i]= 0;
}
}
+ this->unstep.reset();
}
extern "C" void TIMER1_IRQHandler (void){
// If we have no motor to work on, disable the whole interrupt
if(this->active_motor.none()){
LPC_TIM0->TCR = 0; // Disable interrupt
+ tick_cnt= 0;
}
}
acceleration_tick_handlers.push_back(cb);
}
void acceleration_tick();
+ void synchronize_acceleration();
+
void start();
friend class StepperMotor;
// Set the initial speed for this move
this->trapezoid_generator_tick();
+
+ // synchronize the acceleration timer with the start of the new block so it does not drift and randomly fire during the block
+ THEKERNEL->step_ticker->synchronize_acceleration();
}
// Current block is discarded