Hello
I am using S32K312 chip. When problems such as access to illegal addresses or memory out of bounds occur, HardFault interrupt will be entered. In the interrupt, I want to locate the address of the code where the problem occurred by reading registers such as LR/PC. How can I get the value of the relevant register? It cannot be done through Debug. I need to record the register information by storing it in flash or Uart and printing it.
BR,Siomn
Solved! Go to Solution.
Hello,
Well you can step by step debug the code, until you will find instruction which cause the HardFault.
Or you can use the core registers intended to be used for this purpose:
Please refer to following document:
Best regards,
Peter
For viewing the core register in S32DS please refer to:
Hello,
Well, those are core registers, which do not sit on PBRIDGE so you cant read them from direct memory access.
Have a look at the core reference manual:
Google:
These registers can be accessed only by using special register access instruction as they are not memory mapped. 'MSR' instruction is used to write to special register from a general purpose register and 'MRS' instruction is used to read from a special register to a general purpose register.
Best regards,
Peter
Hello,
Thank you for your response.
OK, I would refer to the core reference manual to read the core registers. Could you please tell me where I can get the core reference manual? Or can you please give it to me?
BR, Simon
Hello,
As this is common architecture, simple typing in google search will give you one:
For example here:
Best regards,
Peter
Hello,
Well you can step by step debug the code, until you will find instruction which cause the HardFault.
Or you can use the core registers intended to be used for this purpose:
Please refer to following document:
Best regards,
Peter
For viewing the core register in S32DS please refer to:
HI @petervlna
Thank you for your response.
I hope to record errors that occur during operation, so I cannot obtain exception information through the Debug method. I can only read and save or print the register value in the HardFault interrupt. In addition to the HFSR register you listed in the picture, what are the addresses of other registers such as LR and PC? Can you provide me with a register map? Can this address of 0xE000xxxx be directly accessed in the code?
BR, Simon