NANO54415 RTC issues

Discussion to talk about hardware related topics only.
Post Reply
shockwave77598
Posts: 22
Joined: Sat May 27, 2017 10:38 am

NANO54415 RTC issues

Post by shockwave77598 »

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.
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: NANO54415 RTC issues

Post by TomNB »

Hello,

You didn't mention what example you are running, or your tools version, so I can't give you an exact answer. Are you saying you are running the \nburn\examples\NANO54415\OnChipRtc is not working for you? I do not see #include <rtc.h> in the example, so maybe you are referring to your own application and not the example? In any case, I think the most valuable data point would be if the unmodified example OnChipRtc works for you. I am running 2.9.2.
shockwave77598
Posts: 22
Joined: Sat May 27, 2017 10:38 am

Re: NANO54415 RTC issues

Post by shockwave77598 »

Sorry about that. 2.9.2 is my version also.

I took the example from the onChipRTC example under the Nano54415 directory. That I used as the reference of the code. And the RTC works but doesn't stay working -- it at some point starts constantly giving 00:00 time and quits keeping time.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: NANO54415 RTC issues

Post by pbreed »

Trying to understand your issue:
Board stays powered on, no reboot code reload or reset and RTC goes from working to not working?
shockwave77598
Posts: 22
Joined: Sat May 27, 2017 10:38 am

Re: NANO54415 RTC issues

Post by shockwave77598 »

pbreed wrote: Mon Apr 13, 2020 6:53 am Trying to understand your issue:
Board stays powered on, no reboot code reload or reset and RTC goes from working to not working?
I added the ability to output the time every hour. What I see is the RTC within 24 hours of the time being set, is outputting all 00:00 all the time.

I have managed a work around by taking the system time instead. And I keep it from drifting by refetching the Network time every night at 2am. This is sufficient for the current project. But the RTC test is only good enough for a short term test, whereas what I am seeing happens hours later.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: NANO54415 RTC issues

Post by pbreed »

Can you add a display of the variable Secs...
(Defined in #include <utils.h>

This gets zeroed everytime the board reboots....
I just want to make sure this is really an RTC issue and not a missed power glitch issue...
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: NANO54415 RTC issues

Post by pbreed »

Also since RTC is not preserved across power cycles, the NTP time update is probably best.
The base clock should drift +/- 1.7 seconds a day
Post Reply