2025-12-08 2:04 PM - edited 2025-12-08 2:10 PM
Hi.
I am trying to test out a fault handler for our STM32G (right now, the fault handler just tries to determine the location of the code that caused the fault).
If I force a fault (divide by zero) in "normal" non-interrupt handler code, I can easily read the stack frame, find the PC and determine the location of the fault (stack frame is located in the process stack).
If I force a fault in an interrupt handler (USART1, using HAL code), the stack frame on the main stack does not make sense to me (what I think the PC is, does not point to a location in flash memory). If I add 0x50 to the address in the MSP, then I can see a stack frame with the correct PC.
Is there a section in PM0214 that can explain what I'm seeing?
I attached a few screenshots from the debugger in STM32CubeIDE that show the call stack and memory.
In my example, the MSP in the fault handler points to 0x2001fde8, and the LR is 0xfffffff1. The stack frame I'm expecting to see is at 0x2001fe38.
Thank you!