RTC in TWR-Vybrid doesn't keep time

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RTC in TWR-Vybrid doesn't keep time

3,346 Views
sandrobastos
Contributor IV

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

Labels (3)
Tags (2)
36 Replies

262 Views
naoumgitnik
Senior Contributor V

Dear Sandro,

It is caused by the known hardware issue (https://community.freescale.com/message/343277#343277) and the fact that there is a resistor connected in series with the battery.

With the current too high the voltage on the Vybrid VBAT rail appears to be too low to retain the RTC data, thus, to run such tests on your board, you will have to lower the resistor value.

The new Vybrid revision has this issue fixed so that the new board builds will not have such a problem.

Regards, Naoum Gitnik.


@bruno_c@freescale.com

262 Views
sandrobastos
Contributor IV

Hi Naoum,

I'll make the correction but I'm not sure that is the real problem. When I'm doing the tests, the power of the TWR is not disconnected, I just restart the program and the time is reset. It seems to me to be a software issue.

thank you and regards...

BrunoCastelucci

0 Kudos

262 Views
naoumgitnik
Senior Contributor V

Dear Sandro,

I am just curious if your code works properly, i.e. the RTC time is stored with the J1 shunt staying all the time in the default (1-2) position...

Regards, Naoum Gitnik.


Bruno Castelucci

0 Kudos

262 Views
sandrobastos
Contributor IV

Hi Naoum,

No the time isn't kept even with 3.3V direct (J1 = 1-2). That's why I think it might be a sw issue.

Regards,

0 Kudos

262 Views
naoumgitnik
Senior Contributor V

Dear Sandro,

If this piece of information were provided from the very beginning, a few days would be saved...

juangutierrez, may you comment on the topic-starter's code and/or compare it to what we have, please?

Thanks in advance, Naoum Gitnik.


Bruno Castelucci

0 Kudos

262 Views
karina_valencia
NXP Apps Support
NXP Apps Support

juangutierrez do you have an update on this case?

0 Kudos

262 Views
juangutierrez
NXP Employee
NXP Employee

Sorry, I have been busy with other issues. I have not had chance to check this one.

0 Kudos

262 Views
karina_valencia
NXP Apps Support
NXP Apps Support

Juan,

Please provide estimated due date  to have an update.

0 Kudos

262 Views
juangutierrez
NXP Employee
NXP Employee

Well, I don't think I have a chance to check it this week.

And I'm out next week until January 1st.

I can start checking after the holidays.

0 Kudos

262 Views
sandrobastos
Contributor IV

Hi Juan,

No problem, we'll be back at January 13.

Thank you

0 Kudos

262 Views
karina_valencia
NXP Apps Support
NXP Apps Support

juangutierrez please continue with the follow up.

0 Kudos

262 Views
rendy
NXP Employee
NXP Employee

I'll take it.

262 Views
Nouchi
Senior Contributor II

Hi Sandro,

Did you try to transfer systime to hardware clock :

hwclock --systohc

then read again

hwclock

Emmanuel

0 Kudos

262 Views
sandrobastos
Contributor IV

Hi Emmanuel,

I'm sorry but I didn't understand:

hwclock --systohc

It's supposed to be put in my code? How? Is it a linker command?

Remember I'm using MQX.

thanks...

0 Kudos

262 Views
Nouchi
Senior Contributor II

Hi Sandro,

Sorry, I didn't see you worked with MQX.....

0 Kudos

262 Views
sandrobastos
Contributor IV

No problem Nouchi. Cheers...

0 Kudos