-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Description
On the NRF52832
platform time(NULL)
produces the correct answer for 35 minutes and, afterwards, returns zero or, if set_time()
has been called, the time it was set to, forever and never moves again. Here's a simple test program:
#include "mbed.h"
int main()
{
int wakeUpCount = 0;
time_t waitStartTime = time(NULL);
time_t now;
int x;
printf("Starting up.\n");
//set_time(1);
//waitStartTime = time(NULL);
while (1) {
now = time(NULL);
x = now - waitStartTime;
wakeUpCount++;
printf("%d: started wait at %d, time now %d, difference %d.\n",
wakeUpCount, waitStartTime, now, x);
waitStartTime = time(NULL);
wait_ms(10000);
}
}
mbed compile
it and run it on an NRF52832
platform (I'm using a UBLOX_EVK_NINA_B1
module) and you'll see that time(NULL)
reports 0 forever after the 215th iteration:
212: started wait at 2112, time now 2122, difference 10.
213: started wait at 2122, time now 2132, difference 10.
214: started wait at 2132, time now 2142, difference 10.
215: started wait at 2142, time now 0, difference -2142.
216: started wait at 0, time now 0, difference 0.
217: started wait at 0, time now 0, difference 0.
218: started wait at 0, time now 0, difference 0.
Uncomment the two commented lines and you'll see that time(NULL)
reports 1 forever after the 215th iteration instead:
212: started wait at 2113, time now 2123, difference 10.
213: started wait at 2123, time now 2133, difference 10.
214: started wait at 2133, time now 2143, difference 10.
215: started wait at 2143, time now 1, difference -2142.
216: started wait at 1, time now 1, difference 0.
217: started wait at 1, time now 1, difference 0.
218: started wait at 1, time now 1, difference 0.
FYI, 35 minutes is suspiciously close to going half way around a 32-bit microsecond timer. C'mon guys, this is not on, I've just wasted several days looking for a bug in my code; time()
has to work, it is a complete show-stopper for me if it doesn't, I need a fix/workaround quickly please!!!
- Target:
NRF52832
(in aUBLOX_EVK_NINA_B1
module) - Toolchain: ARM
- mbed-os SHA
40e9f41b4
"Merge pull request Add license files for MTS bootloaders #7821 from klaas019/master" plus the fix toset_time()
in Low power timer needs to be reset when setting time #7849
Issue request type
[ ] Question
[ ] Enhancement
[x] Serious Bug
[ ] I'm going mad