HardFault_Handler - 2 UART channels

I’m new with STM32 and with FREERTOS.

I have 2 tasks (threads):
thread 1: toggle the blue led.
thread 2: is receiving NMEA sentences with UART2 and transmit the UART2 output throw the UART3 channel.

I have configured the FREERTOS according to your instructions (with the blink01/02 example).
but when the threads start to run I get “HardFault_Handler” error…

I tried to search online for solutions and I see you keep saying to follow those links:

First, debugging a hard fault:

Third, making use of configASSERT() to find configuration or user
errors: http://www.freertos.org/a00110.html#configASSERT

but those links don’t explain how to configure clearly and where …

Thanks :slight_smile:

Besides defining configASSERT you should also enable stack overflow checking for development/debugging.
Using assertions can help to catch a number of HardFaults with the possibility to trace back and identify the problem.
Having configASSERT defined (in FreeRTOSConfig.h as documented) makes debugging a lot easier by stopping the debugger if the application hangs. If the hang is caused by an assertion, the application is halted in the forever loop usually the last part of the assertion code (as in example 2) and check the call stack for the cause of the assertion.
Except fatal application programming bugs the main reasons for application crashes are

  1. stack overflows (see above)
  2. wrong interrupt priorities for certain ports/MCUs e.g. with Cortex-M CPUs

STM32 (which one ?) comes with Cortex-M CPUs and the choosen interrupt priorities have to match configMAX_SYSCALL_INTERRUPT_PRIORITY in your FreeRTOSConfig.h
See RTOS for ARM Cortex-M and mabe also this pretty good picture for details.


thank you for the quick answer !!!

I’m using STM32F767

I’ll go over the links and try to add everything you mentioned.

thanks :slight_smile: