简体   繁体   中英

time() ok when debugging (JTAG), not-ok when running on-chip. How to time with an embedded proc?

I'm "playing" with the rm48 board (Texas Instrument RM48L952, ARM CORTEX-R4F), and i want to time a loop (for instance).

char message[20];
int temp=0;
time_t start, end, elapsed; 
sciInit();  

start = time(NULL);
  for(temp=0;temp<0xAAAAAAA;temp++);
end = time(NULL);
elapsed=end-start;
snprintf(message,20,"Duree = %f \r\n",(double)elapsed);
sciSend(scilinREG,20,(unsigned char *)message);

when i'm running the program with the JTAG link and CodeComposerStudio (eclipse-like for C), the display is correct (~4s). But when i'm running the program on-chip (stand alone), the display is incorrect (~637488s) and the same whatever the delay is!

SO, why? I presume the time couting depend on the system... How to time (benchmark program) on an embedded processor?

what is the frequency of the clock that your are using?.have you enabled any interrupts?if so then your program might be getting interrupted and jumping to ISR often and thus increasing the time for looping..sorry i dont have the privilege to comment. also if u want to time the cycles its better to use the in-built timer.

According to ARM's PDF about Dhrystone Benchmarking for ARM Cortex Processors :

Most modern ARM processors include performance counters. They can be programmed to count the number of processor cycles, which can be used to accurately compute the elapsed time. The clock() function must be retargeted to use this feature. [...] In the absence of performance counters and a retargeted clock() function, the semihosted clock() function from the standard C library is used. A debugger capable of supporting semihosting, such as the ARM RealView Debugger (RVD) or DS-5 Debugger must be connected.

Then, I think clock() won't run on-chip. I'm going to use the hardware timers. What do you think about that? Can I use clock() on-chip? And why did it returns such strange duration (63488 etc)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM