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.

Compiler/TMS320C6748: time(NULL) is causing my system to fail

Part Number: TMS320C6748
Other Parts Discussed in Thread: SYSBIOS,

Tool/software: TI C/C++ Compiler

i am using CCS 9.3

code gen tools 7.4.24

custom board

i have found that if i regularly call time(NULL) my system "misbehaves" while it's being called, and it is fine when it isn't

misbehaves include HWI's being way off their schedule, HWI's being blocked for long periods of time, the system becoming unresponsive (because HWI's are misbehaving). essentially it's unusable 

when i do call it it does seem to be returning values that regularly increment.

is time() directly tied to the RTC module? we are not using that in this product but a third party application is trying to use it (which lead me down this path)

  • Hello,

    According to this thread https://e2e.ti.com/support/legacy_forums/embedded/tirtos/f/355/t/310758,

    The RTS time function will get the time from either the RTC, or from the host PC if there is an emulation connection. I'm checking with the TI-RTOS team for more information. Either I or they will follow up with more details. 

    Regards,
    Sahin

  • Hi Michael,

    After conferring with my team, our guess is that since your system behaves badly when calling time(), you probably are not using the BIOS time() function.  Instead you would be using the time() function from the rts library that halts the target and gets the time from the PC.  All you need to do is add the following line to your .cfg file:

     

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

     

    This will cause the BIOS implementation of time() to be pulled in, overriding the time() function from the rts library.  The BIOS time() function is auto-generated from the .cfg file and goes into big.c.

    I hope this helps!

    Megan

  • that worked.

    just so that i understand what is happening

    if we used the RTC module we wouldn't have to do this, but because the RTC module is not used it tries to get it from the host PC connected via emulator, and including this is in SYSBIOS will cause it to get it from SYSBIOS instead.

    so where does SYSBIOS get the value for seconds if we do not have the RTC module in use?

  • Michael,

    Yes, that is correct.

    The BIOS time() function calls Seconds_get() internally which returns the number of seconds since 1970 (the Unix epoch). It is able to call Seconds_get() since the Seconds module gets brought in when the following line is added to your .cfg file (as posted above):

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

    Best,

    Megan

  • i have to repeat a question since you didn't answer it:

    so where does SYSBIOS get the value for seconds if we do not have the RTC module in use?

  • Sorry for the confusion Michael. SYSBIOS gets the value for seconds from the BIOS time() function as described above (i.e. BIOS time() calls Seconds_get() internally which returns the number of seconds since 1970 (the Unix epoch)).

    I hope that answers your question!

  • i think there is still some confusion

    if i don't have a RTC and i don't have an emulator where does sysbios get the time value that it returns? is it a random value at start or is it the number of seconds since the last compile of the code? where does the value itself come from?

  • Michael,

    After some more digging, your device uses a different Seconds delegate than what I was describing above which is used in other devices (e.g. CC26XX). My apologies!

    For TMS320C6748 without an RTC, BIOS time() uses a Clock object to count seconds. The module is ti.sysbios.knl.Clock and the clock object increments its count every second. This is accomplished by configuring the Clock's period to one second. 

    More details about the Clock module can be found in the API documentation for each SYSBIOS version. The documentation for the latest SYSBIOS version (6.82.01.19) can be found here. To highlight a section from the documentation to answer your question regarding where the number starts from:

    "Instances are started when created or they are started later using the Clock_start() function. Instances can be stopped using the Clock_stop() function."

    In that case, the value would be the time elapsed between starting and stopping the instance which would be the number of times the Clock's counter incremented.

    The getTicks() function is also provided which returns the number of clock ticks since startup.

    Best,

    Megan