08-19-2008 10:29 AM - edited 08-19-2008 10:30 AM
Hi everyone,
Is it possible to get the calendar time from the PPC? I need to generate a time stamp, and I was trying to use the standard c library <time.h>. I'm using the standard approach like
time_t now;
struct tm *ts;
char buf[80];
time(&now);
ts = localtime(&now);
strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts);
xil_printf("%s\n", buf);
but I got an error saying that the function "time" is not defined. However, the other functions (localtime and strftime) works OK. Is the function "time" implemented in EDK?
Is there another way to do the same?
Thanks a lot in advance
08-20-2008 11:38 AM
08-20-2008 11:38 AM
08-20-2008 11:52 AM
Thanks for your answer.
It's my first application in embedded systems, and it's a little hard to get used to the new limitations when you have just programmed on an desktop machine :).
So, I'll need to think in another equivalent way.
08-20-2008 07:04 PM
If you just need a timestamp you can use the functions in xtime_l.h, for example:
XTime tstamp;
XTime_GetTime(&tstamp);
XTime_GetTime() returns a 64 bit value in tstamp. The value is read from the PPC internal time base register pair which is incremented with every processor cycle.
08-21-2008 10:22 AM
edk_dingle wrote:
In order for a time function to work it needs a time reference. The time function will not work in a fpga design because there is no time reference available.
Instead, you could use the xps_timer or the internal PPC PIT timers. This can be used to calculate execution time for the sw application. in regards to a time stamp, this information cannot be hard stored in the PPC when the device is powered off because this functionality is not included in Xilinx FPGA's.
You could include a real-time clock chip in your design. Various vendors (ST, Maxim, Epson, do the google) sell these things, and they're cheap, often have a battery backup and they have a simple serial interface that can be connected to the FPGA in the usual fashion.
-a
08-24-2008 09:53 PM
Thanks a lot.
I wanted to know if it was possible. So, I will think in some solution using the timer register.