Search code examples
ctime.hzynq

Implementation of time in Zynq


I'm trying to do a simple STANDALONE application for Zynq. I want to use the 'time.h' to manipulate date/time. I know that there is no hardware implementation on a stanalone BSP, but I want to wire it up on my own. During compilation, when I call 'time(NULL)' I get a error, that there is no implementation of '_gettimeofday()'. I've found it in and implemented it according to the function definition, so that the errors disappear and everything looks ok, but when I run my project on hardware, I see only zeroes from time(). Can anybody help?

Regards, G2


Solution

  • Ok, I've done some research, and found this link. This is almost what I'v been searching, but instead of '_times()' I needed '_gettimeofday()' and this is my implementation:

    int _gettimeofday(struct timeval *__p, void *__tz)
    {
        __p->tv_sec = (systemUsCounter / 1000000);
        __p->tv_usec = systemUsCounter;
        return 0;
    }
    

    I left the '__tz' pointer with no chainges. So this is basicly how to utilize 'time.h' in a standalone application on Zynq.