b7515004da
Whole elapsed seconds are added to secs first, so only the remaining subsecond ticks should then be subtracted from second_countdown in order to decide whether secs should be incremented again. Otherwise, secs is not correctly updated in some cases, typically if the bit 7 of ticks is 1. E.g., with ticks = 128 (i.e. exactly 1 s elapsed) and second_countdown = 128, secs was first incremented as expected, then 128 was subtracted from second_countdown, giving 0 and triggering an unwanted second increment of secs. Or with ticks = 129 (i.e. 1 s + 1 tick) and second_countdown = 1, secs was first incremented as expected, then 129 was subtracted from second_countdown, giving 128 and missing a second increment of secs that should have occurred because second_countdown wrapped around. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> |
||
---|---|---|
.. | ||
6502 | ||
arm | ||
avr | ||
cc253x | ||
cc2430 | ||
cc2538 | ||
mc1322x | ||
msp430 | ||
native | ||
pic32 | ||
stm32w108 | ||
x86 |