How to get the value of the program counter ?
Hello,
Sometimes I have my stm32F7 going in hardfault_handler, so for my customers I have to display on a screen the last address where the software crashed, then I can analyse which problem occure the crash. So I want to get the value "pc" (program counter) like I can see in the Fault Analyzer of stm32cubeide.
I tried many supossed solutions :
__attribute__ ((__noinline__)) void *get_pc()
{
return __builtin_return_address(0);
}or
static __inline__ void *get_pc(void)
{
void *pc;
asm("mov %0, pc" : "=r"(pc));
return pc;
}but it only return the value of the current function called, and not the same value as in the Fault Analyzer of stm32cubeide.
Is there a solution ?
Thank you
