Manage Task

Hello, I’m working with STM32F401RE and FreeRTOS and I’m trying to call a task in a callback of another task. I tried with vTaskSuspend() and vTaskResume() but it’s not working. Any ideas please?

What do you mean exactly by calling a task ?

Thanks, for the fast response. I mean that I want to start another task when, in the callback of another task, i press a specific command.

Although it’s not clear to me what a callback of a task is …
However, you can create tasks in a task. There is no restriction.
What exactly is your problem ?

When task A starts, a callback is called and in this callback, if I press a specific command, I want to change to a task B that do another thing. This is what I want to do but, when I call task B in the callback, it doesn’t work and everything stops.

This description is still unclear. What is calling the callback - is it ISR or timer callback? The best I can infer is that you want to switch to Task B from Task A- the way to do that is not to call the task function but to use some synchronization primitive to signal Task B from Task A. You can use direct to task notification - https://www.freertos.org/RTOS-task-notifications.html

This book is also a good resource to learn about FreeRTOS concepts - https://www.freertos.org/fr-content-src/uploads/2018/07/161204_Mastering_the_FreeRTOS_Real_Time_Kernel-A_Hands-On_Tutorial_Guide.pdf

Thanks.

Thanks a lot. I will try this.

Just another question: I want to create an interruption made by UART that allow to stop all the other tasks and to start the task that I want. There is a way to do that?

You use direct to task notification from ISR to signal a task to start. The same task can stop other tasks. Another way is to use event groups and use a bit for each task - each task waits for a specific bit and only runs when that bit is set.

Ok perfect. Thanks a lot.

What you probably want to implement is what is often called a message pump task, which is a task that sits waiting for external notfications and executes some computation based on the notification request, then goes back to sleep and waits for the next notification. That is normally realized via Mailboxes or other variations of queues. Aside from the resources listed by Gaurav, you may want to look at the tcpip task in FreeRTOS+TCP which also implements a message punp as a template.