当前位置:网站首页>Stm32subemx create semaphore exception analysis

Stm32subemx create semaphore exception analysis

2022-06-09 16:56:00 Running race rabbit

One 、 Encountered a strange problem , Without releasing the semaphore , But it can get the semaphore once and then enter the blocking state

 Insert picture description here
 Insert picture description here

Two 、 solve the problem

1、 Abnormal semaphore appears Create semaphores The function of is vSemaphoreCreateBinary(); ( Note that v), This is an old version Free RTOS Semaphore creation function , When using it to create semaphores UBaseType_t uxMessagesWaiting The default value of is 1,
This means creating semaphore defaults count The value is 1, Therefore, it is possible to obtain a semaphore and enter the blocking state without releasing the semaphore .

2、 The change semaphore creation function is xSemaphoreCreateBinary(); UBaseType_t uxMessagesWaiting The default value of is 0, This is the right situation .

3、 The problem is coming. , I use rtos The version is V10.3 , It's a new version , use stm32cubeide Why is it that semaphores are created vSemaphoreCreateBinary();
 Insert picture description here

3、 ... and 、 Suggest

STM32CUBEMX The configuration of peripherals is very convenient , Is worth to recommend , But yes. Free RTOS Add another layer of packaging , Not very comfortable to use , It is recommended that peripherals can be configured with software ,Free RTOS It is better to add the original version .

原网站

版权声明
本文为[Running race rabbit]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206091629393409.html