STM32 hardfaulthandler does not invoke

Hello, I am facing a hardfault with one of my freertos task on STM32(Register r2 contains 3 on a default handler). I have implemented a hardfault handler as give in http://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html. Debug level is kept as -g3 in the IDE, but these hardfault hanlders functions are never invoked (I put a breakpoint at for( ;; ); in prvGetRegistersFromStack() function). As the hardfault handlers are never invoked I am not able to debug what the actual issue is. Any help will be appreciated. Thanks Milan

STM32 hardfaulthandler does not invoke

If you are ending up in the default handler rather than your own handler that contains the debug code it sounds like you have not actually installed your handler. You need to find the place in the code that sets up the vector table and ensure your handler is installed as the hardfault handler – by default it will probably install the default handler for all the exceptions.

STM32 hardfaulthandler does not invoke

Thank your for the help. May be in my case the Watchdog interrupts are called before reaching the vector tables for hardfault and hardfaultHandler is never invoked. I tried with multiple examples, which may induce a hardfault and in all the cases, the result is the same. So I guess I need to find a way to resolve this WWDG_IRQHandler before.

STM32 hardfaulthandler does not invoke

Hi, Just an update, in my case the issue was that due to the project structure, the hardfault handler defined as a static function as given http://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html was not working. When I changed the function to a normal one, it started working and I could finally catch the culprit. Thanks Milan