diff --git a/timer.c b/timer.c index 3b71b7d..19b358f 100644 --- a/timer.c +++ b/timer.c @@ -103,8 +103,12 @@ void setTimer(uint32_t delay) // we also then calculate the timer ceiling required. (ie what the counter counts to) // the result is the timer counts up to the appropriate time and then fires an interrupt. - setTimerCeiling(getTimerCeiling(delay)); - setTimerResolution(getTimerResolution(delay)); + setTimerResolution(0); // stop timer + TCNT1 = 0; // reset timer + GTCCR = MASK(PSRSYNC); // reset prescaler - affects timer 0 too but since it's doing PWM, it's not using the prescaler + + setTimerCeiling(getTimerCeiling(delay)); // set timeout + setTimerResolution(getTimerResolution(delay)); // restart timer with proper prescaler } // delay( microseconds )