Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


STM32 hardfaulthandler does not invoke

Posted by milanvk on October 12, 2017

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.



STM32 hardfaulthandler does not invoke

Posted by rtel on October 12, 2017

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

Posted by milanvk on October 13, 2017

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

Posted by milanvk on November 16, 2017


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

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner