Creating a EmWin application based on a STM32F746 Disco, using OpenSTM32. I toke the STemWin example application as a starting point. Occasionally (once every 1-3 hours of operation) I'm running into a Hard Fault (stm32f7xx_it.c -> HardFault_Handler()).
The default HardFault_Handler doesn't give me a root cause. I use the description below to further extent the HardFault_Handler.
I have implemented the code below in startup_stm32f746xx.s.
TST LR, #4
MRSEQ R0, MSP
MRSNE R0, PSP
Now when a hard fault occurs the MCU is stuck at line “TST LR, #4”, not sure what I’m doing wrong. Maybe this assembler code is not compatible with Cortex M7?
What is the best and fastest way to track down the actual hard fault root cause on a Cortex M7?