Jump to content
  • 0

Timer on bare metal app


mihai5

Question

 

Hi,

        I want to measure elapsed time in a bare-metal application on the Xilinx Zynq SoC(zedboard).

I included "xtime_l.h" and used XTime_GetTime(&tStart) and XTime_GetTime(&tEnd) to populate tStart and tEnd.

The difference tEnd – tStart always gives me 0 for whatever instructions I put between XTime_GetTime(&tStart) and XTime_GetTime(&tEnd).

Instructions between XTime_GetTime(&tStart) and XTime_GetTime(&tEnd) that I put are:
————————————-

XTime_GetTime(&tStart);
print(“Hello World\n\r”);
for(int i=0;i< 1000 ;i++)
{
sum += i;
}
Xil_Out32(0x43c00000, 0x5);
Xil_Out32(0x7aa00000, 0x5555);
NumberOfPattern = Xil_In32(0x43c00004);

XTime_GetTime(&tEnd)
————————————-

I need to mention that i did not configure the PL part to include an axi_timer IP. I did not do this because, as i read, this uses the global timer in the zynq Soc whose counter increases every two clock cycles.

Can someone to show me where is the mistake and give me some advices?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Hi @mihai5

It is not clear what period of time do you want to measure.

For short periods I had used ARM private timer described in the  Lab 6 of Avnet training materials It does not need configuration in Vivado.

For measurements long period of time with 1 sec accuracy I used Pmod RTCC - real time clock. It was easy to add to the project. The only problem I had was synchonization of time with the computer. This procedure requires a special application passing network time to the RTCC registers.

Good luck!

Link to comment
Share on other sites

@mihai5

I wanted to mention that for using XTime you might need to add to your code

#include "platform.h"  and two statements in the main():

init_platform();

cleanup_platform();

Also in order to get time you can't use xil_printf because it doesn't work on long float type, use

XTime_GetTime(&time); 

printf("t=%15.5lf sec\n",(long double)(time *2)/(long double)XPAR_PS7_CORTEXA9_0_CPU_CLK_FREQ_HZ);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...