This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/CC2640R2F: Retrieving EPOC time from RTC

Part Number: CC2640R2F


Tool/software: TI-RTOS

Hi,

I have used RTC module for setting the UNIX time and I have set the current EPOC time using the Seconds_set() function. The clock continues to count from the provided time but after some time it it reset to a default time (1412800000) and continues to count from that. Whenever I try to read the time using Seconds_get() function i get the latest value but not the value from which I set.

I have used clock modules to count and task sleep to put the device into standby mode. Will this reset the RTC?

Im trying to set unix time and continue to run the clock so that i could retrieve current time and put device to sleep at a particular time everyday. 

Thanks,

radha

  • Hi Radha,

    Do you do any configuration of the RTC itself or do you simply use the Seconds API?

    The Seconds module itself it not configuring anything, it simply reads the RTC value and adds on a fixed offset (based on Seconds_set). There is no good reason for this value to change unless there is another call to Seconds_set().

    The Clock/Task modules should not impact the Seconds module in any way, all three depends on the RTC but they should not be re-configuring the free-running value that the Seconds module depends on.

    Is there any chance that your application happens to perform a software reset somewhere, resetting your Seconds back to your initial state?
  • Hi M_W,

    Thanks a lot for your help. That clarified my doubt.

    Im not configuring the RTC and Im just using the Seconds API.

    I do perform software resets but even when I read the RTC value before the software reset call, I see RTC value has been reset.

    This is how it is.

    Display_print1(dispHandle,0,0, " TIME:%d",time);
    Seconds_set(time);// set to current EPOC time
    t=Seconds_get();
    Display_print1(dispHandle,0,0, "Time t:%d",t);// the set value is printed

    ...........................

    ..........................//lines of code consisting of 30 sec clock in between

    t1=Seconds_get();
    Display_print1(dispHandle,0,0, "Time t1:%d",t1);// the value is printed as 1412800000
    SysCtrlSystemReset(); //After the above statement i perform software reset

    Is it due to the software reset?

    Thanks,
    Radha
  • Hi Radha,

    I assume 1412800000 is the value you configure during Seconds_set()? Could you try to put down alternative "timestamps" and compare as well?

    If you could use the "AONRTCSecGet()" function (from the aon_rtc DriverLib) to read out the RTC value when setting the Seconds value, and when reading out the time before the reset we could verify that the RTC is actually running as expected.
  • Hi M_W,

    I set the value with respect to current time.

    Eg: Seconds_set(1539692282);

    I suppose my Seconds_set() function is not working as expected because whenever I use Seconds_get(), the RTC value returned is incremented from the default value (1412800000 + elapsed time from device boot).

    "If you could use the "AONRTCSecGet()" function (from the aon_rtc DriverLib) to read out the RTC value when setting the Seconds value, and when reading out the time before the reset we could verify that the RTC is actually running as expected"

    I tried the above case for which I got 0 while setting the Seconds value and 30 when reading the time before reset. I hope RTC is working as expected.

    I referred the below document for implementation.

    www.ti.com/.../spruex3u.pdf

    Am I missing something? What could be the case?

    Thanks,

    Radha.

  • Hi Radha,

    Assuming your code runs for 30s, that sounds about right, I don't think the RTC is the problem here. Could you put together a sample project I can test out as I can't seem to re-produce this on my side?
  • Hi M_W,

    I tried the same in simple_peripheral example code and it worked fine without any issues.

    I figured out that in my code I have used Seconds_set() API before init function which apparently caused this issue. But when I set the time after init function, it just worked fine and the value was not resetted. I couldn't figure out the exact reason as to why this occured.

    Thanks for your help and support. I really appreciate it.

    Thanks,

    radha.