arduino-nRF5 icon indicating copy to clipboard operation
arduino-nRF5 copied to clipboard

millis() reset every ~36 hours

Open 0x416c6578 opened this issue 5 years ago • 0 comments

Setting NRF_RTC1->TASKS_TRIGOVRFLW = 1; and the internal overflows variable in delay.c to 255 will cause millis to reset. This is because the overflows variable is ANDed with 0xff so any overflow above 255 is reset to 0, meaning that after 255*((2^24)*(1/32768)) = 130560 seconds or 36.2 hours, the overflow variable is reset and millis drops to 0. This can be fixed by removing the & 0xff on overflows = (overflows + 1) & 0xff; in https://github.com/sandeepmistry/arduino-nRF5/blob/master/cores/nRF5/delay.c so that the overflows variable can increment past 255.

0x416c6578 avatar Jul 12 '20 12:07 0x416c6578