ΣSigmaStudio Ask AI Русский Log in

Why is there a time() function in VDK?

Processors & DSP spflanze May 31, 2012 00:00 3 replies Original on forum ↗
Thread Summary

Thread Summary

The user sought a VDK function to get the number of seconds since Epoch on the BF547 processor. The standard time() function can return -1 if given a NULL pointer or the current calendar time otherwise, but the Blackfin RTC does not maintain the current date and time across reboots. The engineer suggested using the RTC for application-specific time measurement and provided examples from VisualDSP++ Version 5.0 and the Real Time Clock Service in the System Services Manual.
AI Generated Content
Subscribe
spflanze Question
May 31, 2012 00:00

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?

AudeR Reply
May 31, 2012 00:00

Moving this discussion to the Processors and DSP community.

ADIApproved Reply
Jun 8, 2012 00:00

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.

EZAdministrator Reply
Aug 2, 2018 00:00

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