Why is there a time() function in VDK?
For the BF547 processor in I looked for a VDK function that could get the number of seconds since Epoch and found time() at:
C/C++ Compiler and Library Manual for Blackfin Processors > 3 C/C++ Run-Time Library > C Run-Time Library Reference > time
The description's first sentence here seemed to say this was exactly what I needed. And then it goes on to say it will return a value of -1 if the argument is a NULL pointer, or it will output the value passed to it if not NULL. This appears to be a useless function so why is it here? Are there any functions at all that can get and set the number of seconds since Epoch?
Moving this discussion to the Processors and DSP community.
Hi,
According to the ANSI C Standard, the time function either returns -1 or it returns the current calendar time that represents the current date and time. If the result returned by the time function is not -1, then the result can be used by the functions ctime, gmtime, and localtime to 'calculate' the current date and time as either a string or as a broken-down time (in the form of the data type struct tm). However, it can only do so if the current calendar time is 'available' - e.g. some RTOS will configure the current calendar time. glibc uses a similar implementation.
The real time clock (RTC) of the Blackfin processors does contain logic that counts seconds, minutes, hours, and days, and this logic is not reset when the processor is powered-up. However any notion that the processor may have with regards to the current date is lost when the processor is rebooted and thus the real time clock (RTC) does not provide a basis for implementing the time function as defined by the ANSI C Standard.
Depending upon the particular application, it is feasible that the RTC may be used to implement an application-specific version of the time function. The latest release of VisualDSP++ (Version 5.0) contains various programming examples for the Blackfin Processors, one of which is an example for the BF537 EZ-KIT Lite, which demonstrates how to use the RTC to measure elapsed (wall clock) time (specifically the project in the sub-directory Blackfin\Examples\ADSP-BF537 EZ-Kit Lite\Getting Started Examples\Part1_2). See also the Real-Time Clock (ASM).
You may also want to look into using the Real Time Clock Service in the System Services Manual.
Regards,
Craig.
This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.
Thank you,
EZ Admin
Please log in to reply.