vTaskDelete() in FreeRTOS?vTaskDelete() is used to remove a task from the FreeRTOS scheduler, freeing its resources and stopping its execution.
vTaskDelete()?Call vTaskDelete(NULL); to delete the task that is currently running.
The task is removed from the scheduler and its resources are freed regardless of its state (running, blocked, or suspended).
Yes, you can delete any task by passing its handle to vTaskDelete(). For example, vTaskDelete(taskHandle);.
Ensure no other tasks or interrupts try to access the deleted task's resources after deletion to avoid undefined behavior.
vTaskDelete() to delete the current task?Passing NULL tells FreeRTOS to delete the currently running task.
vTaskDelete()?FreeRTOS frees the task's resources so they can be reused.
vTaskDelete() be called from an interrupt service routine (ISR)?vTaskDelete() must be called from a task, not from an ISR.
If the task handle is invalid or NULL (except for current task), vTaskDelete() does nothing.
To avoid errors, ensure no other code accesses deleted task resources.
vTaskDelete() works and how to delete the current task.