Part Number: MSP432P401R
Hello -,
I'm testing code from Section 5.4 "Seconds Module" on page 131 of the SYS/BIOS User's Guide SPRUEX3V—June 2020
Ref: https://www.ti.com/lit/ug/spruex3v/spruex3v.pdf?ts=1628660197039
/* set to today’s date in seconds since Jan 1, 1970 */
Seconds_set(1412800000); /* Wed, 08 Oct 2014 20:26:40 GMT */
/* retrieve current time relative to Jan 1, 1970 */
t = Seconds_get();
I expect it to set the RTC with the time/date given, then immediately retrieve that time/date. I expect "t" to be 1412800000 give or take 1 sec (we're running at 48MHz).
But "t" returns t 1062565248, a difference slightly larger than the expected 1 or 2 seconds.
What gives?
How do I fix this?
Note: time(NULL) agrees with Seconds_get().
Tracing through TI's code, I suspect there's something amiss with the first line called in Seconds_set():
currTime = LOCALTIME((const time_t *)&seconds, &result);
Secondary questions:
Why is TI using localtime() and mktime() when the libs don't offer support for the requisite timezone functions and values? I'd agree timezone support isn't needed on a Cortex-M4 class MCU, but then I'd only support GMT-centric calls gmtime(), timegm(), etc.
The localtime() called is a version from newlib, but CCS didn't install the lib sources. Where can I find TI's source for the following:
/db/ztree/library/trees/newlib/newlib-a00/src/linaro/gcc-arm-none-eabi-7-2017-q4-major/src/newlib/newlib/libc/time/lcltime_r.c
Regards,
-d