*******************************************************************************
The purpose of this demo application is to present a usage of the
Hardfault handling for the S32K3xx MCU.
------------------------------------------------------------------------------
* Test HW: S32K3X2EVB-Q172
* MCU: S32K312
* Compiler: S32DS3.5
* SDK release: RTD 3.0.0
* Debugger: PE micro
* Target: internal_FLASH
********************************************************************************
An example on S32K312:
Read an unimplemented memory (0x80000):
volatile uint32_t read = *((uint32_t*)0x00080000);
Hardfault will occur :--
Dinesh_Guleria_7-1707886997375.png
Dinesh_Guleria_8-1707887021604.png
Dinesh_Guleria_0-1707887578380.png
Read Stack pointer when the HARDFAULT occur :--
SP = 0x2000ffd0
Dinesh_Guleria_0-1707886133591.png
Go to this memory location , 0x2000ffd0 :--
Dinesh_Guleria_1-1707886185039.png
Dinesh_Guleria_2-1707886314115.png
When the program enters an exception handler, the stack frame is pushed onto the stack including the program counter value of the fault instruction.
At exception entry, the processor saves R0 R3, R12, LR, PC and PSR on the stack.
Dinesh_Guleria_3-1707886498124.png
hardfault occurred at, 0x00400e48, this is how to decode the address :--
Dinesh_Guleria_5-1707886661636.png
Dinesh_Guleria_2-1707886314115.png
Now How to reach this address 0x00400e48, using disassembly window :--
This is same place in main() function :--
volatile uint32_t read = *((uint32_t*)0x00080000);
Dinesh_Guleria_6-1707886853788.png