How to get the fault cause on KL03 for a Hard Fault?

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

How to get the fault cause on KL03 for a Hard Fault?

451 Views
gauravbanyal
Contributor IV

Hello,

 

I am running into some random hard faults and I would like to get more information on whats causing it.

Would be great if I can get a custom HardFault_Handler function that reads the right registers to find the cause of the hard fault.

 

I read many forums posts but haven't got a direct answer.

 

Thanks for your help!

 

Gaurav.

Labels (1)
Tags (1)
0 Kudos
2 Replies

318 Views
BlackNight
NXP Employee
NXP Employee

Hi Gaurav,

there is a hard fault handler widely used for Cortex-M listed here:

Debugging Hard Faults on ARM Cortex-M

If using gdb, you can use the one listed here with GDB scripts:

Debugging ARM Cortex-M Hard Faults with GDB Custom Command

You can find the hard fault handler on GitHub:

McuOnEclipseLibrary/McuHardFault.c at master · GitHub 

I hope this helps,

Erich

0 Kudos

318 Views
gauravbanyal
Contributor IV

Hi Erich,

I am using Keil for development on my KL03z and I don't have processor expert mode.

I have actually seen these links before but I couldn't get much out of those.

Would be nice if I could get a HardFault_Handler() function implemented so that it captures the ARM registers just before entering the fault handling and captures the fault status registers.

Thanks,

Gaurav.

0 Kudos