cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
helena
Observer
Observer
1,890 Views
Registered: ‎02-08-2018

How to measure time using an ARM R5 processor?

Hi,

I'm using a Zynq Ultrascale+ ZCU104 board with a software application created in Xilinx SDK and I'm trying to measure the time some functions take to execute. Normally I'd use the following code:

XTime start;
XTime end;
double total_time;

XTime_GetTime(&start);
do_something();
XTime_GetTime(&end);

total_time = 1.0 * (end - start) / COUNTS_PER_SECOND;

The code above works if I execute the code in the ARM A53 processor, however, I was trying the ARM R5 processor and I get the following errors:

unknown type name 'XTime'
'COUNTS_PER_SECOND' undeclared (first use in this function); did you mean 'ITERS_PER_SEC'?

If I open the `xtime_l.h`, these sections are greyed out, SLEEP_TIMER_BASEADDR is not defined. 

#ifdef SLEEP_TIMER_BASEADDR

#define COUNTS_PER_SECOND				SLEEP_TIMER_FREQUENCY
#define COUNTS_PER_USECOND 				COUNTS_PER_SECOND/1000000

/* The following definitions are applicable only when TTC3 is present*/
#ifdef SLEEP_TIMER_BASEADDR
typedef u32 XTime;

void XTime_SetTime(XTime Xtime_Global);
void XTime_GetTime(XTime *Xtime_Global);
#endif

I have these options defined instead, but I'm not sure if I'm supposed to use them instead, since I don't have any functions defined that allow me to obtain a current value:

#define ITERS_PER_SEC  (XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ / 4)
#define ITERS_PER_USEC  (XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ / 4000000)
#define IRQ_FIQ_MASK 	0xC0	/* Mask IRQ and FIQ interrupts in cpsr */

Does anybody know how to measure time using the R5 processor? Thank you so much in advance.

0 Kudos
9 Replies
1,843 Views
Registered: ‎07-23-2019

Probably the R5 doesn't use the sleep timer.

Why don't you just type the bloody frequency of your R5 core there instead of expecting witty defines you didn't write to work as you want?

Remember: K.I.S.S.

0 Kudos
helena
Observer
Observer
1,826 Views
Registered: ‎02-08-2018

Sure, I can define the "bloody frequency" of my R5 core but how am I supposed to use it if the time function ( XTime_GetTime() ) is not defined?

0 Kudos
1,729 Views
Registered: ‎07-23-2019

 

I see... your problem is more than this:

The code above works if I execute the code in the ARM A53 processor, however, I was trying the ARM R5 processor and I get the following errors:

unknown type name 'XTime'
'COUNTS_PER_SECOND' undeclared (first use in this function); did you mean 'ITERS_PER_SEC'?

 

The functions are also greyed out. Why? is there an ifdef greying it out? What does it say?

 

0 Kudos
helena
Observer
Observer
1,718 Views
Registered: ‎02-08-2018

Yes, there is. I mention it in my question:

As I say above, SLEEP_TIMER_BASEADDR is not defined which results in greying out the functions. Without these functions, I have no idea how to count the execution time.

#ifdef SLEEP_TIMER_BASEADDR
typedef u32 XTime;

void XTime_SetTime(XTime Xtime_Global);
void XTime_GetTime(XTime *Xtime_Global);
#endif

 

0 Kudos
blindobs
Adventurer
Adventurer
1,709 Views
Registered: ‎09-13-2018

Can't you just configure and use TTC/RTC for time measure ? I think it doesn't require A53 running
0 Kudos
1,695 Views
Registered: ‎07-23-2019

@helena 

aha. Have you the RTC enabled?

 

Untitled picture.png

You might also need to tweak the BSP settings regarding the sleep timer:

Untitled picture.png

0 Kudos
helena
Observer
Observer
1,666 Views
Registered: ‎02-08-2018

I do, yes, the functions are greyed out with RTC enabled. I've already tried to change that option in the BSP, however, I got the following error:

ERROR	: (XSDB Server)ERROR: [Hsi 55-1545] Problem running tcl command ::sw_standalone_v6_8::generate : ERROR: psu_cortexr5 does not support psu_iou_scntr 
    while executing
"error "ERROR: $proctype does not support $sleep_timer ""
0 Kudos
1,625 Views
Registered: ‎07-23-2019

 

It looks like the RPU doesn't support the sleep timer which sounds weird to me.

0 Kudos
shirilt
Xilinx Employee
Xilinx Employee
1,063 Views
Registered: ‎05-15-2018

I'm not sure why SLEEP_TIMER_BASEADDR is not defined in your case. This #define comes from the file xparameters.h, which is populated when the R5 BSP is created in SDK. The relevant lines for this are: https://github.com/Xilinx/embeddedsw/blob/release-2019.2/lib/bsp/standalone/data/standalone.tcl#L891

In the above, you can see that the SLEEP_TIMER_BASEADDR will not be defined if the sleep timer source is specified as iou_scntr or iou_scntrs in the BSP configuration.

I created a R5 BSP using a basic HDF (the one provided with the embedded design tutorial UG1209). In the BSP configuration, I let the sleep timer source to it's default value of 'none'. This should be fine based on the TCL script above, since it will be assigned to TTC3 by default. As expected, in my case, SLEEP_TIMER_BASEADDR is defined as follows in xparameters.h and corresponds to the TTC3 instance

Capture.PNG

In xtime_l.h, I see the following which indicates that SetTime() and GetTime() are available for use:

Capture_1.PNG

 

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos