RTC Configuration

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

RTC Configuration

Jump to solution
2,618 Views
Jairo
Contributor III

Hi, i was working with an application using the RTC module, but i'm getting troubles with it. I based my code on the rtc example but apparently the System Clock is not working, i make consults to the time struct with an event, and then print it to terminal, but always display 00d 00hrs 00m 00s, the initialization code is posted below. I begin to have this problem when i implemented the ADC and another task that is checking for several alarms setted (this task has a _time_delay of 60s).

 

 

//__________________RTC_______________
    _rtc_init(RTC_INIT_FLAG_CLEAR | RTC_INIT_FLAG_ENABLE);
 _rtc_get_time (&time_rtc);
 _rtc_time_from_mqx_time (&time_mqx, &time_rtc);
 _rtc_time_to_mqx_time (&time_rtc, &time_mqx);
    printf ("MQX: %d s, %d ms\n", time_mqx.SECONDS, time_mqx.MILLISECONDS);
 printf ("    (%d d, %d hr, %d m, %d s)\n", time_rtc.days, time_rtc.hours, time_rtc.minutes, time_rtc.seconds);

 In the function for set the clock to the actual time:

 

printf("Tiempo guardado: %d:%d:00", hora,min);
 time_rtc.hours=hora;
 time_rtc.minutes=min;
 time_rtc.seconds=0;
 _rtc_set_time(&time_rtc);
 _rtc_get_time (&time_rtc);  
 printf ("MQX: %d s, %d ms\n", time_mqx.SECONDS, time_mqx.MILLISECONDS);
    printf ("    (%d d, %d hr, %d m, %d s)\n", time_rtc.days, time_rtc.hours, time_rtc.minutes,time_rtc.seconds);
 sendCMD(CLR_SCR);
 sendCMD(HOME);
    sendString(str2);

 The struct has the configured parameters but it doesn't change.

This last code fragment is in the event part, it is suppossed that this will show the time. Worked for me before including the ADC task.

 

    _rtc_get_time (&time_rtc);  
 printf ("MQX: %d s, %d ms\n", time_mqx.SECONDS, time_mqx.MILLISECONDS);
     printf ("    (%d d, %d hr, %d m, %d s)\n", time_rtc.days, time_rtc.hours, time_rtc.minutes, time_rtc.seconds);

 

 The MQX time never changes its value, always is zero for seconds and milliseconds.

 

 it's necesary som kind of trigger or refresh function for the time struct?

Thanks in advance.

 

 

 

0 Kudos
Reply
1 Solution
1,101 Views
PetrM
Senior Contributor I

Hello,

 

it seems to me that in your event RTC code you don't translate RTC time to MQX time.

That's why it's always zero.

Try this:

 

_rtc_get_time (&time_rtc);  

_rtc_time_to_mqx_time (&time_rtc, &time_mqx);
printf ("MQX: %d s, %d ms\n", time_mqx.SECONDS, time_mqx.MILLISECONDS);
printf ("    (%d d, %d hr, %d m, %d s)\n", time_rtc.days, time_rtc.hours, time_rtc.minutes, time_rtc.seconds);

 

Or if you want to see current MQX time, use this function instead: 

_time_get (&time_mqx); 

 

 

Regards,

PetrM

 

Message Edited by PetrM on 2009-12-07 03:34 PM

View solution in original post

0 Kudos
Reply
3 Replies
1,102 Views
PetrM
Senior Contributor I

Hello,

 

it seems to me that in your event RTC code you don't translate RTC time to MQX time.

That's why it's always zero.

Try this:

 

_rtc_get_time (&time_rtc);  

_rtc_time_to_mqx_time (&time_rtc, &time_mqx);
printf ("MQX: %d s, %d ms\n", time_mqx.SECONDS, time_mqx.MILLISECONDS);
printf ("    (%d d, %d hr, %d m, %d s)\n", time_rtc.days, time_rtc.hours, time_rtc.minutes, time_rtc.seconds);

 

Or if you want to see current MQX time, use this function instead: 

_time_get (&time_mqx); 

 

 

Regards,

PetrM

 

Message Edited by PetrM on 2009-12-07 03:34 PM
0 Kudos
Reply
1,101 Views
Jairo
Contributor III

Hi. i'm currently using the M52259DEMO board, as far as i know it doesn't need some jumpers for the RTC, correct me if i'm wrong.

 

 

Best Regards

0 Kudos
Reply
1,101 Views
JaimeR
Contributor III

What hardware are you using?, any of the evaluation boards?

Do you have the Jumpers correctly selected to power up the RTC module?

 

Message Edited by Jaime R on 2009-12-04 11:07 PM
0 Kudos
Reply