DSPRelated.com
Forums

Question about C Runtime Routine CLOCK()

Started by William C Bonner March 29, 2006
The following set of routines will compile just fine, and work when I'm
connected to the board via JTAG, but without the external clock of my
computer, they will not work correctly. How can I provide support for a
real time clock in a DSP routine? Is there a simple way of building a
timer tick system work?

I need to keep track of real timer ticks for producing status messages
to the outside world. Is there and internal DSP timer that I can use
for this purpose?

#include
#include

time_t timer;
time(&timer);
printf("\t clock() = %u\r\n",clock());
printf("\t GMT Time = %s",asctime(gmtime(&timer)));
printf("\t Local Time = %s",asctime(localtime(&timer)));
wim,

--- William C Bonner wrote:

> The following set of routines will compile just
> fine, and work when I'm
> connected to the board via JTAG, but without the
> external clock of my
> computer, they will not work correctly.
Correct. The clock() and stdio functions are
performed by the host [v-e-r-y s-l-o-w-l-y]. They
should only be used for debug [when you can 'spare the
time'] and testing [results, timestamps, etc].

> How can I
> provide support for a
> real time clock in a DSP routine?
Your DSP [I forget which one that you are using] has
one or more timers that can be read for reference
and/or used to generate interrupts.

> Is there a simple
> way of building a
> timer tick system work?
Yes. I don't have any code snippets handy, but if you
use CSL to initialize it, it is pretty straight
forward. You might check the archives and/or TI's web
site for an example.

mikedunn
>
> I need to keep track of real timer ticks for
> producing status messages
> to the outside world. Is there and internal DSP
> timer that I can use
> for this purpose?
>
> #include
> #include time_t timer;
> time(&timer);
> printf("\t clock() = %u\r\n",clock());
> printf("\t GMT Time > %s",asctime(gmtime(&timer)));
> printf("\t Local Time > %s",asctime(localtime(&timer)));
> c...
>
>
>
The chip that I'm using is the 6713. It has two Timer resources.
Unfortunately, the hardware that I'm using is already making use of both
of those timer resources, and I've not got access to that module
currently. I'm still hoping that I'll recover the resource, but that's
politics.

One of the things that I've been wondering about is what happens if I'm
making library calls such as from the TI FFT calls documented in
spru657b.pdf. Those FFT calls are described as: Interruptibility: This
code is interrupt-tolerant but not interruptible.

What I've taken that to mean is that the code will actually disable
interrupts, or at least interrupts will not be serviced while the
function itself is running. So, if I'm incrementing a tick value based
on the interrupt from timer1, is it possible that it will get missed
some of the time?
Mike Dunn wrote:
> --- William C Bonner wrote:
>
>
>> The following set of routines will compile just fine, and work when I'm
>> connected to the board via JTAG, but without the external clock of my
>> computer, they will not work correctly.
>>
> Correct. The clock() and stdio functions are
> performed by the host [v-e-r-y s-l-o-w-l-y]. They
> should only be used for debug [when you can 'spare the
> time'] and testing [results, timestamps, etc].
>
>
>> How can I provide support for a
>> real time clock in a DSP routine?
>>
> Your DSP [I forget which one that you are using] has
> one or more timers that can be read for reference
> and/or used to generate interrupts.
>
>
>> Is there a simple
>> way of building a
>> timer tick system work?
>>
> Yes. I don't have any code snippets handy, but if you
> use CSL to initialize it, it is pretty straight
> forward. You might check the archives and/or TI's web
> site for an example.
>
> mikedunn
>
>> I need to keep track of real timer ticks for producing status messages
>> to the outside world. Is there and internal DSP timer that I can use for this purpose?
>>
>> #include
>> #include
>>
>> time_t timer;
>> time(&timer);
>> printf("\t clock() = %u\r\n",clock());
>> printf("\t GMT Time = %s",asctime(gmtime(&timer)));
>> printf("\t Local Time = %s",asctime(localtime(&timer)));
>>