cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UARTEx_ReceiveToIdle_IT Causing Hard fault

JThom.15
Associate III

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


_legacyfs_online_stmicro_images_0693W00000bVeq9QAC.png
_legacyfs_online_stmicro_images_0693W00000bVf4xQAC.pngany help would be much appreciated

3 REPLIES 3
Bob S
Principal

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.

Going to need to show what instructions are at/before the PC to contextualize the failure.

Do a disassembly.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..