I am working on a stopwatch project and I need to read the time that has passed while the program is running and build my time base from that.
I've included the time.h
library and even put the .h file in my project directory but for some reason once I use clock()
function my code doesn't build correctly on this or any of my atmel 7 projects.
I included a simple coded that I believe should compile, as well as the errors I get when I try and build. I suspect the problem has something to do with atmel 7, but any other suggestions would be appreciated.
#include <time.h>
#include <avr/io.h>
#include <stdio.h>
int main()
{
clock_t start_t, end_t, total_t;
int i;
start_t = clock();
printf("Starting of the program, start_t = %ld\n", start_t);
printf("Going to scan a big loop, start_t = %ld\n", start_t);
for(i=0; i< 10000000; i++)
{
}
end_t = clock();
printf("End of the big loop, end_t = %ld\n", end_t);
total_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;
printf("Total time taken by CPU: %ld\n", total_t );
printf("Exiting of the program...\n");
return(0);
}
ERRORS:
recipe for target 'clocktest3.elf' failed
undefined reference to 'clock'
id returned 1 exit status