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> |
||
---|---|---|
.. | ||
dev | ||
usb | ||
cc2538.lds | ||
clock.c | ||
cpu.c | ||
cpu.h | ||
dbg.c | ||
dbg.h | ||
debug-uart.h | ||
ieee-addr.c | ||
ieee-addr.h | ||
lpm.c | ||
lpm.h | ||
Makefile.cc2538 | ||
mtarch.h | ||
reg.h | ||
rtimer-arch.c | ||
rtimer-arch.h | ||
slip-arch.c | ||
spi-arch.h |