Skip to main content
DLim.16
Associate III
February 14, 2020
Solved

CMSIS RTOS V1 Semaphore issues in STM32CubeIDE

  • February 14, 2020
  • 3 replies
  • 2803 views

Hi,

I am using STM32F405, CMSIS RTOS V1, and STM32CubeIDE. I want to create a timer interrupt that periodically release the semaphore to signal the execution of a task.

The issue is that it gets stuck after osSemaphoreRelease is called in the interrupt. Please refer to my source code.

How do I troubleshoot this?

Thanks.

This topic has been closed for replies.
Best answer by KnarfB

Dont think so, because Semaphore1Handle is passed as a parameter to the task.

In the task you are checking if the semaphore was created., makes sense.

But, in HAL_TIM_PeriodElapsedCallback you are not checking.

Maybe the first IRQ comes too early. Try shifting the line HAL_TIM_Base_Start_IT(&htim3); down.

3 replies

Karl Yamashita
Principal
February 15, 2020

You have two different semaphores. One that looks like CubeMX created "Semaphore1Handle" which you release. Then you create another in StartDefaultTask "semaphore" which you wait on.

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
KnarfB
KnarfBAnswer
Super User
February 15, 2020

Dont think so, because Semaphore1Handle is passed as a parameter to the task.

In the task you are checking if the semaphore was created., makes sense.

But, in HAL_TIM_PeriodElapsedCallback you are not checking.

Maybe the first IRQ comes too early. Try shifting the line HAL_TIM_Base_Start_IT(&htim3); down.

DLim.16
DLim.16Author
Associate III
February 17, 2020

I did that, and it worked, thanks!!!

Pavel A.
Super User
February 15, 2020

osSemaphoreRelease is a RTOS API. Do you think it can be called from an interrupt handler? and is the priority of the interrupt low enough to use RTOS calls?

-- pa