640 views|3 replies

321

Posts

1

Resources
The OP
 

osPriorityRealtime tasks cannot be terminated [Copy link]

 This post was last edited by shipeng on 2024-3-23 16:02

When I was configuring FreeRTOS with STM32CubeIDE recently, I found that after the osPriorityRealtime level task is created, it cannot be terminated before the kernel is started (calling the function osKernelStart()), otherwise it will cause a HardFault exception interrupt. As for whether the task can be terminated after the kernel is started, I did not try. My operation is to create the task REMOTE_CMDHandle in the function void MX_FREERTOS_Init(void), and call osThreadTerminate(REMOTE_CMDHandle) before the MX_FREERTOS_Init function returns; and clear the task handle REMOTE_CMDHandle = NULL; my original intention was to prevent the REMOTE_CMDHandle task from running after powering on, and wait for user operation before creating and running it. Since the task will be powered on and run by default after using STM32CubeIDE graphical creation, I added a sentence of task termination after creation to achieve my ulterior purpose.

Debug tracking found that the specific reason was that when the stack initialization function pxPortInitialiseStack returned, it entered the prvIdleTask function->prvCheckTasksWaitingTermination()->( void ) uxListRemove( &( pxTCB->xStateListItem ) ) and ran to "if( pxList->pxIndex == pxItemToRemove )", an illegal address 0xfffffffd appeared, triggering the HardFault_Handler() abnormal interrupt. The final solution was to set the priority to osPriorityHigh and successfully solve the problem. To delve into the specific reasons, we need the guidance of the masters.

Latest reply

Manual processing. Extract this part of the code.   Details Published on 2024-3-26 15:42
Personal signature模电临时工
 

6748

Posts

2

Resources
2
 

Does it mean that when you want to boot up, you should first stop the thread created by the GUI task?

Comments

Yes, it is mainly because the task is not allowed to run when powered on, or my original intention is not to create a task when powered on, but STM32CubeIDE does not seem to have this option. As long as you add a task to the .ioc file, the task is created in the FRERTOS_Init() function by default and you have no choice.  Details Published on 2024-3-25 20:08
 
 
 

321

Posts

1

Resources
3
 
wangerxian posted on 2024-3-25 15:17 Does it mean that when you want to start the computer, you should stop the thread created by the GUI task first?

Yes, it's mainly because the task is not allowed to run when powered on, or I originally didn't want to create a task when powered on, but STM32CubeIDE doesn't seem to have this option. As long as you add a task in the .ioc file, the task is created in the FRERTOS_Init() function by default and you have no choice. Of course, you can also choose to create the task manually without this problem, but I didn't do this and encountered a problem. I hope it can help someone who is destined to do so.

Comments

Manual processing. Extract this part of the code.  Details Published on 2024-3-26 15:42
 
Personal signature模电临时工
 
 

7422

Posts

2

Resources
4
 
shipeng posted on 2024-3-25 20:08 Yes, it is mainly because the task is not allowed to run when powered on, or my original intention is not to create a task when powered on, but STM32CubeIDE does not seem to have...

Manual processing. Extract this part of the code.

 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list