0
0
FreeRTOSprogramming~30 mins

vTaskDelete() for task removal in FreeRTOS - Mini Project: Build & Apply

Choose your learning style9 modes available
Using vTaskDelete() to Remove Tasks in FreeRTOS
📖 Scenario: You are working on a FreeRTOS-based embedded system where multiple tasks run concurrently. Sometimes, you need to stop a task that is no longer needed to free system resources.
🎯 Goal: Learn how to create a task, then remove it safely using vTaskDelete().
📋 What You'll Learn
Create a task function that toggles an LED
Create the task using xTaskCreate()
Use vTaskDelete() to remove the task
Print messages to show task creation and deletion
💡 Why This Matters
🌍 Real World
In embedded systems, tasks that are no longer needed should be removed to save memory and CPU time. Using <code>vTaskDelete()</code> helps manage system resources efficiently.
💼 Career
Understanding task creation and deletion is essential for embedded software developers working with FreeRTOS or similar real-time operating systems.
Progress0 / 4 steps
1
Create a task function called vLEDTask
Write a task function called vLEDTask that takes a void *pvParameters parameter and contains an infinite loop with a comment // Toggle LED here inside the loop.
FreeRTOS
Need a hint?

Task functions in FreeRTOS have the form void TaskName(void *pvParameters) and usually run an infinite loop.

2
Create the task using xTaskCreate()
Use xTaskCreate() to create the task vLEDTask with the name "LED Task", stack size configMINIMAL_STACK_SIZE, no parameters (NULL), priority 1, and store the task handle in a variable called xLEDTaskHandle.
FreeRTOS
Need a hint?

Remember to pass the address of the task handle variable to xTaskCreate() to store the created task's handle.

3
Delete the task using vTaskDelete()
Use vTaskDelete() to delete the task using the handle stored in xLEDTaskHandle.
FreeRTOS
Need a hint?

Pass the task handle to vTaskDelete() to remove the task.

4
Print messages to show task creation and deletion
Add printf() statements to print "Task created" after creating the task and "Task deleted" after deleting the task.
FreeRTOS
Need a hint?

Use printf() before and after the task creation and deletion calls to show messages.