Homepage  

xTaskCreate
[Task Creation]

task. h
portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, const portCHAR * const pcName, unsigned portSHORT usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pvCreatedTask );

Create a new task and add it to the list of tasks that are ready to run.

Parameters:
pvTaskCode Pointer to the task entry function. Tasks must be implemented to never return (i.e. continuous loop).
pcName A descriptive name for the task. This is mainly used to facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN.
usStackDepth The size of the task stack specified as the number of variables the stack can hold - not the number of bytes. For example, if the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes will be allocated for stack storage. The stack depth multiplied by the stack width must not exceed the maximum value that can be contained in a variable of type size_t.
pvParameters Pointer that will be used as the parameter for the task being created.
uxPriority The priority at which the task should run.
pvCreatedTask Used to pass back a handle by which the created task can be referenced.
Returns:
pdPASS if the task was successfully created and added to a ready list, otherwise an error code defined in the file projdefs. h
Example usage:
// Task to be created. void vTaskCode( void * pvParameters ) { for( ;; ) { // Task code goes here. } }

// Function that creates a task. void vOtherFunction( void ) { unsigned char ucParameterToPass; xTaskHandle xHandle;

// Create the task, storing the handle. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );

// Use the handle to delete the task. vTaskDelete( xHandle ); }





Copyright (C) 2003 - 2008 Richard Barry
Any and all data, files, source code, html content and documentation included in the FreeRTOS distribution or available on this site are the exclusive property of Richard Barry. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Richard Barry.