64-bit cycle counter on Cortex-R5

228 Views Asked by At

By configuring the PMU of the Cortex-R5 it's possible to get a cycle count. However the counter is 32-bit, which means it wraps after some seconds. Is there a way to get or emulate a 64-bit counter?

1

There are 1 best solutions below

0
On

Option 1 - Set PMCR.D to 1 and count every 64 cycles, to trade accuracy for range, which effectively gives you a 38-bit counter.

Option 2 - Set up PMINTENSET to raise an interrupt on a 32-bit overflow and write a small driver to accumulate into a 64-bit value in software. This relies on the PMU IRQ being wired up to the interrupt controller; it normally is but isn't guaranteed.