I try to read CNTFRQ register with inline assembly code. I use the following:
I encountered two issues:
I tried to use "regular" syntax which I saw in other places as well and it didn't work.
static uint32_t freq = 0;
__asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
I don't know what is wrong with this syntax:
I tried another syntax:
__asm
{
mrc p15, 0, freq, c14, c0, 0
}
Now the code compiles but I have two problems:
There is no volatile statement
When I execute this asm code via debugger it halts when it reaches the asm code and that's it (I don't see the print value and can't continue to next step or running the debugger)
Although many compilers use GNU's inline assembly syntax (what you call "regular syntax"), the syntax of inline assembly is not standardized and many compilers use a different syntax.
Obviously, your compiler is one of them.
There is no
volatile
statement
You must check the compiler manual for the correct syntax of inline assembly. Maybe the compiler always treats inline assembly the way GNU C/C++ would treat __asm volatile
.
When I execute this asm code via debugger it halts when it reaches the asm code and that's it
The CNTFRQ
register is not mentioned in the Cortex-A9 manual. Are you sure that this register exists on your CPU?