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/TM4C123GH6PM: Date / TIME in TI-RTOS

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi all,

I'm using TI-RTOS for Tiva C, CCS7, compiler 16.9.1, XDC 3.32.1.22.

I need to save the date and time in my program. I use the following code : 

In my .cfg file, I 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 I 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));

My problem is that the time doesn't update, It seems the function ti_sysbios_hal_Seconds_get() using by time() doesn't give the new seconds.

Can someone give me some advises to solve this problem ?

Thanks in advance,

Cheers,

Pierre Gogendeau

  • I don't use TI-RTOS, I don't know how many in this forum do but the things I'd check first are do you have the RTC initialized and running correctly? I'd verify that before connecting it to the RTOS.

    Robert
  • Hi Pierre,

    Can you confirm the time() function is being generated properly? Look in the Debug\configPkg\package\cfg directory of the project that builds the kernel. You'll see a 'C' file called <.cfg_name>_p<linker format>.c. It's a big file. Search for time() and can you post what it looks like?

    It should look something like this

    /*
    * ======== time ========
    */
    time_t ATTRIBUTE time(time_t *tout)
    {
    UInt32 t;

    /* Seconds_get() returns number of seconds since Jan 1, 1970 00:00:00 GMT. */
    t = ti_sysbios_hal_Seconds_get();

    #if defined(__ti__)
    /*
    * TI time() function returns seconds since 1900, so add the number
    * of seconds from 1900 to 1970 (2208988800).
    */
    t += 2208988800;
    #endif

    if (tout) {
    *tout = t;
    }

    return (t);
    }

    Also, can you confirm that Seconds_get is working?

    Todd
  • Hi Robert,

    Thanks for your fast answer. I will check this first you're right.

    Pierre

  • Hi Todd,

    My function time() was right and it was my function Seconds_get() which had a problem. After checking Seconds.c I have seen that seconds_get() use a macro used for the hibernation mode too "HWREG(x)". In my code before using the timer I forgot to remove HibernateDisable() ( I used it when I did some tests for the hibernation mode). It working now, thanks for your help.

    Pierre
  • Glad you found the issue.