From Libc.pdf page 141:
6.2 clock--cumulative processor time
Synopsis
#include <time.h>
clock_t clock(void);
Description
Calculates the best available approximation of the cumulative amount of time used by your
program since it started. To convert the result into seconds, divide by the macro CLOCKS_PER_SEC.
Returns
The amount of processor time used so far by your program, in units de_ned by the machinedependent
macro CLOCKS_PER_SEC. If no measurement is available, the result is -1.
Portability
ANSI C requires clock and CLOCKS_PER_SEC.
Supporting OS subroutine required: times.
The compiler generates an error and goes into an infinite loop trying to compile this. The error message is
times.c: undefined reference to ‘times’
Do I need to include something else??
Steve
Cumulative Processor Time
Re: Cumulative Processor Time
Just use the global variable, Secs. Its the seconds since boot time.
Re: Cumulative Processor Time
The compiler doesn't crash, but I get this:
Who maintains libc for this platform?
Looks like an error in libc.c:/nburn/gcc-m68k/bin/../lib/gcc/m68k-elf/4.2.1/../../../../m68k-elf/lib/m5208\libc.a(lib_a-times.o): In function `_times_r':
times.c:(.text+0xe): undefined reference to `times'
Who maintains libc for this platform?
Re: Cumulative Processor Time
What is the value get? The description you included for clock() appears to say it a way to get seconds since boot. Are you trying to get seconds?
Re: Cumulative Processor Time
Seems that the result is a function of CLOCKS_PER_SEC.rnixon wrote: What is the value get? The description you included for clock() appears to say it a way to get seconds since boot. Are you trying to get seconds?
The description seems to indicate that the value returned will be CLOCKS_PER_SEC/value. In my case CLOCKS_PER_SEC == 20.
"Cumulative amount of time" is misleading as the unit of measure is not stated until you read the description.
I wanted something with more resolution than a second. Meanwhile I found a nice timer class that provides about 3ms resolution and even has a callback.
Amazing what folks have produced here.
Re: Cumulative Processor Time
There is a TICKS_PER_SECOND #define that has a default of 20, and this is what the system clock uses, and Secs and TimerTicks are based on it. But this is not accurate enough in some cases, so one of the unused hardware timers can be used (I think thats what your referring to). There is a thread on a stopwatch function that might be interesting as well:
http://forum.embeddedethernet.com/viewt ... ?f=7&t=397
http://forum.embeddedethernet.com/viewt ... ?f=7&t=397
Re: Cumulative Processor Time
I just thought I would mention BspGetTickFraction() again, it lets you get a value of finer granularity without using a timer or interrupt. I mentioned some details about it in this thread..