Skip to main content
Davy Jones
Associate II
April 3, 2018
Solved

Terminate and restart a task ?

  • April 3, 2018
  • 2 replies
  • 5003 views
Posted on April 03, 2018 at 11:08

We have project in which FreeRTOS code is generated using CubeMx.   I see syntax is little different from documentation on FreeRTOS site. 

How can I terminate and restart a particular task?

Main objective is 

  • Terminate and restart a task causing HardFault
  • Restart a crashed task

Want to know how to restarting a task in FreeRTOS code generated from CubeMx 

Majerle.Tilen.001

‌

Can you please help in this regard ?

#task #restart #freertos+hal #terminate #tasks
This topic has been closed for replies.
Best answer by Tilen MAJERLE
Posted on April 05, 2018 at 21:44

STM32Cube adds additional layer of function for CMSIS OS compliancy (

http://www.keil.com/pack/doc/CMSIS/RTOS/html/index.html

). You can check there for FreeRTOS functions.

To terminate thread, use osThreadTerminate function and to start new thread, use osThreadCreate. 

In case you enter hardfault, the best is to restart your system as if your CPU jumped to unknown memory location (in terms of instructions), you might have hard time to recover it to the right instruction and stack pointer.

2 replies

Tilen MAJERLE
Tilen MAJERLEBest answer
ST Employee
April 5, 2018
Posted on April 05, 2018 at 21:44

STM32Cube adds additional layer of function for CMSIS OS compliancy (

http://www.keil.com/pack/doc/CMSIS/RTOS/html/index.html

). You can check there for FreeRTOS functions.

To terminate thread, use osThreadTerminate function and to start new thread, use osThreadCreate. 

In case you enter hardfault, the best is to restart your system as if your CPU jumped to unknown memory location (in terms of instructions), you might have hard time to recover it to the right instruction and stack pointer.

Visitor II
October 15, 2024

I have tried terminating and creating the same thread using osThreadTerminate and osThreadNew, but i am entering into hardfault.

hardfault_fault_analyzer..png

Is there any method to recover it to the right instruction and stack pointer.