NANO54415 RTC issues
Posted: Sun Apr 12, 2020 9:41 am
I'm trying to use the RTC on the Nano54415.
I figured out that the include was wrong by looking at the RTC exmaples. So I did this:
//#include <rtc.h>
#include <mcf5441x_rtc.h>
I am able to set the system time with NTP just fine.
iprintf("Getting time from NTP\r\n");
if ( SetTimeNTPFromPool() )
{
iprintf("Time set\r\n");
MCF541X_RTCSetRTCfromSystemTime();
}
As the OS iterates 20 times a second, I count for 20*60 and then make a read of the RTC once per minute
if (MCF541X_RTCGetTime( rtctime )) // 1 if error
{
iprintf("RTC Fail - %02d:%02d ", rtctime.tm_hour, rtctime.tm_min);
}
I never get any error. But the data from the RTC does get hosed, with it becoming 00:00 at all times
I am puzzled what I'm doing wrong here. It'll run a random time without problem, then suddenly reading
the RTC gives you junk data. I'm only reading it once per minute - surely that isn't too much. I do so because
system clock isn't as accurate as the RTC.
I figured out that the include was wrong by looking at the RTC exmaples. So I did this:
//#include <rtc.h>
#include <mcf5441x_rtc.h>
I am able to set the system time with NTP just fine.
iprintf("Getting time from NTP\r\n");
if ( SetTimeNTPFromPool() )
{
iprintf("Time set\r\n");
MCF541X_RTCSetRTCfromSystemTime();
}
As the OS iterates 20 times a second, I count for 20*60 and then make a read of the RTC once per minute
if (MCF541X_RTCGetTime( rtctime )) // 1 if error
{
iprintf("RTC Fail - %02d:%02d ", rtctime.tm_hour, rtctime.tm_min);
}
I never get any error. But the data from the RTC does get hosed, with it becoming 00:00 at all times
I am puzzled what I'm doing wrong here. It'll run a random time without problem, then suddenly reading
the RTC gives you junk data. I'm only reading it once per minute - surely that isn't too much. I do so because
system clock isn't as accurate as the RTC.