From b85b575b9b815b15af0a26604235b8d8e6194f65 Mon Sep 17 00:00:00 2001 From: Simen Svale Skogsrud Date: Wed, 3 Mar 2010 22:55:45 +0100 Subject: [PATCH] added protection against retriggering stepper irq --- stepper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stepper.c b/stepper.c index ecf62cb..ea043e0 100644 --- a/stepper.c +++ b/stepper.c @@ -50,6 +50,7 @@ uint8_t out_bits; struct Line *current_line; volatile int32_t counter_x, counter_y, counter_z; uint32_t iterations; +volatile busy; void config_step_timer(uint32_t microseconds); @@ -96,9 +97,11 @@ SIGNAL(SIG_OUTPUT_COMPARE1A) TCNT2 = -(((STEP_PULSE_MICROSECONDS-4)*TICKS_PER_MICROSECOND)/8); // Enable interrupts in order for SIG_OVERFLOW2 to be able to be triggered // and reset the stepper signal even before this handler is done. Needed - // to generate a clean stepper-signal even if this is going to be a time consuming + // to generate a clean stepper-signal in the event that this is going to be a time consuming // time oround in this interrupt e.g. if we just completed a line and need to - // set up another. + // set up another. The busy-flag is used to avoid retriggering this interrupt. + if(busy){return;} + busy = TRUE; sei(); // If there is no current line, attempt to pop one from the buffer @@ -149,6 +152,7 @@ SIGNAL(SIG_OUTPUT_COMPARE1A) out_bits = 0; } out_bits ^= STEPPING_INVERT_MASK; + busy=FALSE; PORTD &= ~(1<<3); }