2023-06-05 06:32 PM - edited 2023-11-20 03:53 AM
I was using HAL_UARTEx_ReceiveToIdle_IT to receive data on modbus. After running for couple minutes without any issues it hits the HardFault_Handler.
My registers at the time of HardFualt
any help would be much appreciated
2023-06-06 09:37 AM
You need to look at the fault registers (CFSR, and possibly MMFAR and BFSR). CubeIDE has a built-in fault analyzer. Those registers will tell you the PC of the instruction that failed. Also search the forums for fault handler for links to some sample code.
You don't say which CPU you are using. On at least some of the M4 CPUs the bus fault, usage fault and memory manager faults are disabled by default. And when disabled these are automatically escalated to a hard fault.
2023-06-06 09:40 AM
Going to need to show what instructions are at/before the PC to contextualize the failure.
Do a disassembly.
2023-06-06 10:20 AM
For HAL check instances/structures are initialized and passed correctly before use by interrupts.
Some CMx are more sensitive that others to alignment.
The faulting code should provide insight into the specific pointers or records causing grief.