optimize print_position to use string and reduce stack usage.
[clinton/Smoothieware.git] / src / libs / StepTicker.cpp
index 99373fb..0fc72c6 100644 (file)
@@ -37,12 +37,12 @@ StepTicker::StepTicker()
 
     // Configure the timer
     LPC_TIM0->MR0 = 10000000;       // Initial dummy value for Match Register
-    LPC_TIM0->MCR = 3;              // Match on MR0, reset on MR0, match on MR1
+    LPC_TIM0->MCR = 3;              // Match on MR0, reset on MR0
     LPC_TIM0->TCR = 0;              // Disable interrupt
 
     LPC_SC->PCONP |= (1 << 2);      // Power Ticker ON
     LPC_TIM1->MR0 = 1000000;
-    LPC_TIM1->MCR = 1;
+    LPC_TIM1->MCR = 5;              // match on Mr0, stop on match
     LPC_TIM1->TCR = 0;              // Disable interrupt
 
     // Default start values
@@ -71,6 +71,7 @@ void StepTicker::start()
 {
     NVIC_EnableIRQ(TIMER0_IRQn);     // Enable interrupt handler
     NVIC_EnableIRQ(TIMER1_IRQn);     // Enable interrupt handler
+    current_tick= 0;
 }
 
 // Set the base stepping frequency
@@ -132,8 +133,6 @@ void StepTicker::handle_finish (void)
 // step clock
 void StepTicker::step_tick (void)
 {
-    static uint32_t current_tick = 0;
-
     //SET_STEPTICKER_DEBUG_PIN(running ? 1 : 0);
 
     // if nothing has been setup we ignore the ticks
@@ -149,6 +148,8 @@ void StepTicker::step_tick (void)
 
     if(THEKERNEL->is_halted()) {
         running= false;
+        current_tick = 0;
+        current_block= nullptr;
         return;
     }
 
@@ -219,7 +220,7 @@ void StepTicker::step_tick (void)
 
     // see if any motors are still moving
     if(!still_moving) {
-        SET_STEPTICKER_DEBUG_PIN(0);
+        //SET_STEPTICKER_DEBUG_PIN(0);
 
         // all moves finished
         current_tick = 0;
@@ -261,8 +262,10 @@ bool StepTicker::start_next_block()
         motor[m]->start_moving(); // also let motor know it is moving now
     }
 
+    current_tick= 0;
+
     if(ok) {
-        SET_STEPTICKER_DEBUG_PIN(1);
+        //SET_STEPTICKER_DEBUG_PIN(1);
         return true;
 
     }else{