AnsweredAssumed Answered

RTC in TWR-Vybrid doesn't keep time

Question asked by Sandro Bastos on Dec 11, 2013
Latest reply on Dec 11, 2014 by Sandro Bastos

Hi,

 

I'm working with TWR-VF65GS10 and IAR, using MQX.

My code sets a time and then I comment the code and start my program again (reset). When I read the RTC back, it has came back to 01-01-1970, 0h.

I already changed the J1 to position 2-3 (Vbat comes from battery) and, obviously, put the battery.

 

Could anyone share any solution? Thanks....

 

My code is as follow (taken from this forum):

 

void setTimeFromDate(uint_32 year, uint_32 month, uint_32 day, uint_32 hour,

                       uint_32 minute, uint_32 second, uint_32 millisec){

    TIME_STRUCT  MQX_time;

    DATE_STRUCT  DateStruct;

    RTC_TIME_STRUCT RTC_time;

 

    DateStruct.YEAR = (uint_16)year;

    DateStruct.MONTH = (uint_16)month;

    DateStruct.DAY = (uint_16)day;

    DateStruct.HOUR = (uint_16)hour;

    DateStruct.MINUTE = (uint_16)minute;

    DateStruct.SECOND = (uint_16)second;

    DateStruct.MILLISEC = (uint_16)millisec;

    _time_from_date(&DateStruct, &MQX_time);//Convierte la fecha a tiempo MQX

    _rtc_time_from_mqx_time (&MQX_time, &RTC_time);

    _rtc_set_time (&RTC_time);

}

 

void getDateFromTime() {

 

    TIME_STRUCT  MQX_time;

    DATE_STRUCT  DateStruct;

    RTC_TIME_STRUCT RTC_time;

 

    _rtc_get_time (&RTC_time);

    _rtc_time_to_mqx_time ( &RTC_time, &MQX_time);

    _time_to_date(&MQX_time, &DateStruct );

 

}

 

@bruno_c@freescale.com

Outcomes