Fix timer for high speeds.

This commit is contained in:
Markus Amsler 2011-02-08 11:10:11 +01:00 committed by Michael Moon
parent 8ebce94e4d
commit d5033895b2
1 changed files with 5 additions and 0 deletions

View File

@ -100,9 +100,14 @@ void setTimer(uint32_t delay)
timer1_compa_isr(); timer1_compa_isr();
} }
else if (next_step_time <= TICK_TIME) { else if (next_step_time <= TICK_TIME) {
// next step occurs before overflow, set comparator here
OCR1A = next_step_time & 0xFFFF; OCR1A = next_step_time & 0xFFFF;
TIMSK1 |= MASK(OCIE1A); TIMSK1 |= MASK(OCIE1A);
} }
else {
// adjust next_step_time so overflow interrupt sets the correct timeout
next_step_time -= TICK_TIME;
}
} }
else { else {
next_step_time = 0; next_step_time = 0;