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.

Using Hibernate Tivaware API's in TI-RTOS

Hello,

We are implementing a data logger using SD card. This requires data logged to be time-stamped with date and time.  Can we directly use the tiva-ware hibernate APIs to read the RTC directly and use the same for time stamping with date and time.  I was also looking into timestamp module  of SYS/BIOS. It just gives an 32 bit number.  How do we correlate this 32 bit number into a real time date/time? Is there a way to convert this into time and date?  

HW: DK-TM4C-129X

SW: TI-RTOS 2.10.  SYS/BIOS 6.41

CCS 6.0

Thanks in Advance

Narendra

  • in continuation to the above post:
    Can we use hibernate module as plain RTC module for calendar function (We do not need hibernation )

    TIA
    Narendra
  • Hi Narendra,

    TI-RTOS has the support for the functionality that you are looking for.  The Seconds module can be used to setup the wall clock on your device (TI-RTOS NDK also has support for SNTP in case you would like to sync the wall clock with the NTP servers). Once the wall clock is setup, the C std time APIs like ctime() can be used to get real time/date.

    For example: 

    In your .cfg file, add:

    var Seconds = xdc.useModule('ti.sysbios.hal.Seconds');

    In your application .c code, include:

    #include <ti/sysbios/hal/Seconds.h>
    #include <time.h>
    

    and add the following code:

    time_t ts;
    /* Set the current time in seconds since epoch */
    Seconds_set(1432145807);
    ts = time(NULL);
    System_printf("%s", ctime(&ts));

    Hope it helps,

    Vikram

  • how do I calculate seconds since epoch to use with Seconds_set. if I use RTC, I can get the input from user and write to the RTC registers. is there any function to calculate the seconds since epoch if given the date and time. One brute way of doing this is to calculate the number of days since epoch and calculate it by multiplying it with 24*3600. This would be a very crude way of doing it.

    Any pointers in this direction would be helpful

    TIA
    Narendra
  • There are few ways that you can setup Seconds_set():

    Vikram