MCF541X_RTCSetTime( struct tm &bts ) problem
Posted: Thu Oct 17, 2013 6:50 pm
I use the MOD54415 and test the RTC onboard. On myPost function from my WebHandler I extract the data like this: (sorry my variable is in french)
My function SetSystemDateTime is :
For set the year to 2013, I write -143 in the year field on my web page. If I use the RTC from the developpement board I don't have this problem I write 2013 in the year field and the date is set correctly.
If I see the RTC section from the reference manuel MCF5441x the register to store the year is 8 bits (signed Byte) and is an offset to the 2112. So 2112 - 2013 = 99 (0x9D) I should write -99 to this field to obtain the 2013... no i need to write -143.
Another problem when I send to stdout from my run function the RTC pass from 31 december to 00 december ?!!?
I wait for yours comments about this RTC.
Code: Select all
...
else if(httpstricmp( rxBuffer, "POST /FORMDATETIME" ))
{
char AnneeInput[5];
char MoisInput[3];
char JourInput[3];
char HeureInput[3];
char MinuteInput[3];
ExtractPostData( "Annee", pData, AnneeInput, MAX_BUF_LEN );
ExtractPostData( "Mois", pData, MoisInput, MAX_BUF_LEN );
ExtractPostData( "Jour", pData, JourInput, MAX_BUF_LEN );
ExtractPostData( "Heure", pData, HeureInput, MAX_BUF_LEN );
ExtractPostData( "Minute", pData, MinuteInput, MAX_BUF_LEN );
iprintf("Date et heure dopost: %s %s %s %s %s",AnneeInput,MoisInput,JourInput,HeureInput,MinuteInput);
SetSystemDateTime(AnneeInput,MoisInput,JourInput,HeureInput,MinuteInput);
...
Code: Select all
void WebServerHandler::SetSystemDateTime(char *AnneeInput, char *MoisInput,char *JourInput,char *HeureInput,char *MinuteInput)
{
tm InputDateTime;
InputDateTime.tm_year = atoi(AnneeInput);
//InputDateTime.tm_year = InputDateTime.tm_year - 2112;
InputDateTime.tm_mon = atoi(MoisInput) - 1;
InputDateTime.tm_mday = atoi(JourInput);
InputDateTime.tm_hour = atoi(HeureInput);
InputDateTime.tm_min = atoi(MinuteInput);
InputDateTime.tm_sec = 0;
//RTCSetTime( InputDateTime);
MCF541X_RTCSetTime( InputDateTime);
//RTCSetSystemFromRTCTime();
MCF541X_RTCSetSystemFromRTCTime();
tm SettingRTC;
RTCGetTime(SettingRTC);
char buffer [80];
strftime (buffer,80,"Now it's %F:%R.",&SettingRTC);
iprintf("Date Time from RTC: %s", buffer );
}
If I see the RTC section from the reference manuel MCF5441x the register to store the year is 8 bits (signed Byte) and is an offset to the 2112. So 2112 - 2013 = 99 (0x9D) I should write -99 to this field to obtain the 2013... no i need to write -143.
Another problem when I send to stdout from my run function the RTC pass from 31 december to 00 december ?!!?
My run function look like this:Date Time from RTC: Now it's 2013-12-31:23:59:58.
Date Time from RTC: Now it's 2013-12-31:23:59:59.
Date Time from RTC: Now it's 2013-12-00:00:00:00.
Code: Select all
void DoorController::Run()
{
tm SettingRTC;
char buffer [80];
while (1)
{
OSTimeDly(5);
//RTCGetTime(SettingRTC);
MCF541X_RTCGetTime( SettingRTC );
SettingRTC.tm_year = SettingRTC.tm_year;
strftime (buffer,80,"Now it's %F:%T.",&SettingRTC);
iprintf("Date Time from RTC: %s\r\n", buffer );
}
}