Freertos semaphore initialised wrong in CubeMX
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-06-19 9:09 AM
CubeMX always generates binary semaphores with an initial count of 1 (full) in CMSIS-RTOS2, even if the user wants the semaphore to start depleted (count = 0). There is no option to set the initial count to depleted during configuration, but when generating the code, it will be with initial count of 1.
/* creation of myBinarySem01 */
myBinarySem01Handle = osSemaphoreNew(1, 1, &myBinarySem01_attributes);
/* creation of myBinarySem02 */
myBinarySem02Handle = osSemaphoreNew(1, 1, &myBinarySem02_attributes);
only way I solve it is acquiring the semaphore after creating it
* USER CODE BEGIN RTOS_SEMAPHORES */
/* add semaphores, ... */
osSemaphoreAcquire(myBinarySem02Handle, 10);
/* USER CODE END RTOS_SEMAPHORES */
Labels:
- Labels:
-
STM32CubeMX
-
STM32U5 series
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-06-19 9:16 AM
A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
A complex system designed from scratch never works and cannot be patched up to make it work.
