rdtsc equivalent on v4?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

rdtsc equivalent on v4?

787 Views
klaus
Contributor I
Hi,

does anyone have an idea how to best get something equivalent to the x86 rdtsc instruction on a v4 core (mcf548x specifically) for reading out a cycle count?

I was considering using the second slice timer to count down from ffffffff, read the SCNT register  use the inverted value. The problem with that is that this is supposed to work from userspace, and the MBAR region is locked down to kernel accesses.

Thanks!
Klaus
Labels (1)
0 Kudos
2 Replies

340 Views
mon3al
Contributor I

Hi,

Did you ever come up with a solution to this. I'm trying measure CPU clock frequency. I was thinking of counting instructions in a loop and them using a timer to measure the time it took.

0 Kudos

340 Views
TomE
Specialist II

I program a spare DMA Timer to free-run at an appropriate rate, and use that for all "real time" measurements. Having it run at 1MHz is very convenient for the software as it doesn't involve any "human time to clock tick" conversions.

 

The following assumes that the timer is running:

 

/* * Define an architecture-neutral microsecond function. For * the mcf5329 CPU we're suing DMA Timer 1 to count * microseconds. */#define DEBUG_US()  (MCF_DTIM1_DTCN)

...
uint32_t nTimer = DEBUG_US();

... Do whatever ...

nTimer = DEBUG_US() - nTimer;
printf("Whatever took %dus\n", nTimer);

 Tom

 

0 Kudos