simulator: fix timer overflow problem
Next-interrupt-time calculations were made in 16-bit registers but moved to 32-bit ones for convenience. But they forgot to round off at 16-bits. Force the round-off so we do not wait forever.
This commit is contained in:
parent
1e2824d56b
commit
18ea439788
|
|
@ -115,13 +115,13 @@ void sim_setTimer() {
|
|||
//-- Calculate time in clock ticks until next timer events
|
||||
if (TIMSK1 & MASK(OCIE1A)) {
|
||||
sim_debug("Timer1 Interrupt A: Enabled");
|
||||
nextA = OCR1A - now;
|
||||
nextA = (OCR1A - now) & 0xFFFF ;
|
||||
// 0 = No timer; 1-0x10000 = time until next occurrence
|
||||
if ( ! nextA) nextA = 0x10000;
|
||||
}
|
||||
if (TIMSK1 & MASK(OCIE1B)) {
|
||||
sim_debug("Timer1 Interrupt B: Enabled");
|
||||
nextB = OCR1B - now;
|
||||
nextB = (OCR1B - now) & 0xFFFF;
|
||||
// 0 = No timer; 1-0x10000 = time until next occurrence
|
||||
if ( ! nextB) nextB = 0x10000;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue