I'm using the RTC in the processor of the MOD 54415. I have a battery connected to Vstandby to keep the RTC (and 2kRAM) powered when the main supply is off.
Software wise I'm using the system function MCF541X_RTCSetSystemFromRTCTime() to set the system time on power up and MCF541X_RTCSetTime(dateTime) to set the RTC date/time when the user uses a clock setting page in the web server interface.
In normal use with the power on, my software gets date / time information from the system time. The RTC is only accessed on power on to set the system time.
The problem that I notice is that if the unit is powered off over a month end, the next time it is switched on the date can be 1 day out (either ahead or behind). This is fairly obviously the RTC thinking the month transition that just occurred was a 30 day month when it was a 31 day month (which would cause the date to advance to the 1st of the next month when it should be the 31st of the previous month ie be one day ahead), or a 31 day month when it was a 30 day month (which would cause the date to not advance to the 1st of the next month until a day late ie be one day behind).
Looking at the RTC system code in C:\nburn\MOD5441X\system the problem seems pretty obvious just by looking at the comments and a quick read of the Freescale Ref Manual for the 54415.
The system code uses a dateTime structure of type tm. In the comments the month element of this is described as having values of 0 to 11
Code: Select all
* int tm_mon; // Month of the year [January(0)-December(11)]
But in the code the system time 0 to 11 value seems to be directly applied to the RTC month byte
Code: Select all
WORD ym=(WORD)year|(WORD)bts.tm_mon;
...
sim2.rtc.yearmon = ym;
Code: Select all
ym =sim2.rtc.yearmon;
bts.tm_mon=(ym&0xff); // Month of the year [January(0)-December(11)]
To correct this surely when setting the RTC 1 needs to be added to the month and when reading 1 needs to be subtracted?
But I can't believe no one else has found this and reported it?
If I fix this by editing the code in "C:\nburn\MOD5441X\system\mcf5441x_rtc.cpp" do I then need to use the NBEclipse menu "Rebuild Modified System Files"?
Thanks