Skip to main content
Associate
July 6, 2025
Solved

xSemaphoreCreateBinay() crash IOs

  • July 6, 2025
  • 1 reply
  • 392 views

IDE : STM32CubeIDE Version: 1.16.1
Board : STM32F407VG DISC1
SYS Timebase Source : TIM6

Hello,
In my project, i use I2C and multiple UARTs. It worked fine before adding FreeRTOS tasks. Recently i need add buttons to my project, so i add a new task to handle interrupts. To synchonize my EXIT ISR (callback) and the button handling task, a binary semaphore is adpoted.

Strange things happened, after creating a binary semaphore with xSemaphoreCreateBinary(), all I/Os, I2C and UARTs, are failed. Even HAL_Delay() did not work, bebugger died in HAL_GetTick() in HAL_Delay. all abnormalities happened before starting FreeRTOS kernel and initializing tasks. Commenting the xSemaphoreCreateBinary() system is back to normal.

Can someone tell me what causes the problem.

Best answer by Sarra.S

Hello @sinolegend

Could you share xSemaphoreCreateBinary()?

Potential causes could be heap/stack corruption or a conflict of HAL timebase (using TIM6), so try increasing the heap size and make sure TIM6 is not used by both HAL and RTOS.  

 

1 reply

Sarra.SBest answer
ST Employee
July 7, 2025

Hello @sinolegend

Could you share xSemaphoreCreateBinary()?

Potential causes could be heap/stack corruption or a conflict of HAL timebase (using TIM6), so try increasing the heap size and make sure TIM6 is not used by both HAL and RTOS.  

 

Associate
July 14, 2025

thank you for your suggestion.  enlarging my heap/stack size  does solve my semaphore creation problem.  could you show me how to do your another reminder "make sure TIM6 is not used by both HAL and RTOS"?