On a Raspberry Pi 3b, which is ARM Cortex-A5 processor, ARMv7 architecture, I am reading the cycle counter registers from the PMU (Performance Monitor Unit):
uint32_t cycle_counter_read (void){ uint32_t cc = 0; __asm__ volatile ("mrc p15, 0, %0, c9, c13, 0":"=r" (cc)); return cc;}
uint32_t cycle_counter_read (void)
{
uint32_t cc = 0;
__asm__ volatile ("mrc p15, 0, %0, c9, c13, 0":"=r" (cc));
return cc;
}
I'd like to understand on which ARM processors will this code run successfully, other than the one in Raspberry Pi 3B.
Which ARM info is important for this:
Currently I have included this code only for ARMv7:
#if defined(PLATFORM_ARMV7)
cycle_counter_read();
#endif
Thanks.
Other architectures have a cycle counter in a different place. in ARMv7m, for example, there is DWT->CYCCNT in the Debug, Watchpoint, and Trace unit.