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.

TMS320F28379D: CLOCK_REALTIME is undefined showed!

Part Number: TMS320F28379D
Other Parts Discussed in Thread: CONTROLSUITE

Hello,

I am trying to print out time and date but CLOCK_REALTIME is undefined showed!. Can anyone give me a feedback what is the reson behind that.

#include "F28x_Project.h"
#include <string.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "utils/cmdline.h"
#include "utils/uartstdio.h"
#include "utils/ustdlib.h"
#include "third_party/fatfs/src/ff.h"
#include "third_party/fatfs/src/diskio.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/_timespec.h>
#include <sys/_types.h>

struct timespec start;
struct tm *today;
__clockid_t clk_id = CLOCK_REALTIME;
clock_gettime(clk_id, &start);
today = localtime(&start);

  • Mukesh,

    I'm working to get a proper answer from the SW perspective here, but I can say from a HW perspective that the C2000 MCU does not have a real-time clock on the device for this function to reference.

    Best,

    Matthew

  • Assuming you're using the posix files in SYS/BIOS, it looks like CLOCK_REALTIME is defined in bios_6_83_00_18\packages\ti\posix\ccs\time.h. You have a time.h file included in your code, but do you know if it's the same one?

    Whitney

  • Hello Whitney Dewey,

    In the time.h header file there wasn't any defined value of CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_THREAD_CPUTIME_ID and CLOCK_PROCESS_CPUTIME_ID. That's is one reason and then Control Card Delfino F28379D has no RTC module built-in.

    Kind regards

    Mukesh Ghosh

  • Hello Matthew and Whitney,

    Currently, I am using time function to get a timer clock but it cant give a highest precision in micro second or nano second. For getting time precision in micro or nano second I need to use clock_gettime or gettimeofday function. But unfortunately time.h header file provied from Texas Instrument (TI) haven't any implementation of clock_gettime and TI haven't provided #include<sys/time.h> header file which support gettimeofday fuction. My code is working with time(NULL) function but I need more precision for my project. If you guys can give me any suggestions, it will be really helpful for me. Thanks in advance.

    Kind regards

    Mukesh Ghosh

    //current implementation

    time_t rawtime = time(NULL);
    struct tm *today;
    today = localtime(&rawtime);

  • I'm looking at the clock.c file C:\ti\bios_6_83_00_18\packages\ti\posix\tirtos and can see an implementation of clock_gettime(). Is that not what you're using?

    Whitney

  • Or is the problem that it isn't building when you call it in your code? Like I mentioned, ti\posix\ccs\time.h does contain a #define for CLOCK_REALTIME. Is that folder not on the include path?

    Whitney

  • Hello Whitney Dewey,

    I haven't found any path name "C:\ti\bios_6_83_00_18\packages\ti\posix\tirtos". I am opening a example code from code "C:\ti\controlSUITE\device_support\F2837xD". I dont have any path related to bios_6_83_00_18. Can you please tell me how can I get this bios file , am I need to install some software from TI?. On the other hand, inside my clock.c header file there is no implementation of clock_gettime() function. Please let me inform if you have any suggestions.

    Kind regards

    Mukesh Ghosh

  • What implementation of the time functions are you using? Are you implementing them yourself? I had assumed you were using the SYS/BIOS implementation of the posix functions since that is the only one I am aware of for C2000 devices. Sorry for the confusion.

    Whitney