S32K312-How to get the value of registers such as LR/PC in Hard_Fault interrupt?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K312-How to get the value of registers such as LR/PC in Hard_Fault interrupt?

Jump to solution
1,004 Views
Simon-Liu
Contributor V

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

0 Kudos
Reply
1 Solution
991 Views
petervlna
NXP TechSupport
NXP TechSupport

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:

petervlna_0-1703847320043.png

Please refer to following document:

https://community.nxp.com/t5/S32K-Knowledge-Base/How-To-Debug-A-Fault-Exception-On-ARM-Cortex-M-V7M-...

Best regards,

Peter

 

For viewing the core register in S32DS please refer to:

https://community.nxp.com/t5/S32-Design-Studio/How-to-view-NVIC-registers-in-S32-Design-Studio-for-A...

 

View solution in original post

5 Replies
957 Views
petervlna
NXP TechSupport
NXP TechSupport

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:

petervlna_0-1704186410517.png

petervlna_1-1704186712816.png

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

0 Kudos
Reply
956 Views
Simon-Liu
Contributor V

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

0 Kudos
Reply
938 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

As this is common architecture, simple typing in google search will give you one:

For example here:

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwiAiKem1b6DAxWf3gIHHbmMByoQ...

Best regards,

Peter

0 Kudos
Reply
992 Views
petervlna
NXP TechSupport
NXP TechSupport

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:

petervlna_0-1703847320043.png

Please refer to following document:

https://community.nxp.com/t5/S32K-Knowledge-Base/How-To-Debug-A-Fault-Exception-On-ARM-Cortex-M-V7M-...

Best regards,

Peter

 

For viewing the core register in S32DS please refer to:

https://community.nxp.com/t5/S32-Design-Studio/How-to-view-NVIC-registers-in-S32-Design-Studio-for-A...

 

967 Views
Simon-Liu
Contributor V

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

0 Kudos
Reply