Fix timer for high speeds.
This commit is contained in:
parent
8ebce94e4d
commit
d5033895b2
5
timer.c
5
timer.c
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue