cancel
Showing results for 
Search instead for 
Did you mean: 

CMSIS RTOS V1 Semaphore issues in STM32CubeIDE

DLim.16
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

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.

View solution in original post

4 REPLIES 4
Karl Yamashita
Lead III

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.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
KnarfB
Principal III

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.

Pavel A.
Evangelist III

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

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