From 926d74fcb7c93434ce9acf24d08c0dd59908a278 Mon Sep 17 00:00:00 2001 From: jvangrin Date: Tue, 5 Jul 2011 16:50:40 -0500 Subject: [PATCH] Reset the overflow flag to stop a queued overflow interrupt from resetting the step pulse right after sei() is called --- stepper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stepper.c b/stepper.c index 5b4efcc..3f33c18 100644 --- a/stepper.c +++ b/stepper.c @@ -135,8 +135,10 @@ SIGNAL(TIMER1_COMPA_vect) // Then pulse the stepping pins STEPPING_PORT = (STEPPING_PORT & ~STEP_MASK) | out_bits; // Reset step pulse reset timer so that The Stepper Port Reset Interrupt can reset the signal after - // exactly settings.pulse_microseconds microseconds. + // exactly settings.pulse_microseconds microseconds. Clear the overflow flag to stop a queued + // interrupt from resetting the step pulse too soon. TCNT2 = -(((settings.pulse_microseconds-2)*TICKS_PER_MICROSECOND)/8); + TIFR2 |= (1<