Geting PC register value

Guest #2749395
Rate this post
useful
not useful
Hello,

I use gcc to compile my code for STM32F407VGT6. I am trying to print the 
value of PC register and in order to do this I use this code:

unsigned int pc_value;

__asm__("mov %%R15,%0" : "=r" (pc_value));

My application crashes when it executes this line. If I replace R15 with 
another register (R1 for example) it does not crash anymore.
Is this because I am not allowed to read the value of PC ?

Thanks.

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now