Core Function: Task Function

From ChipKit Wiki

Jump to: navigation, search

Syntax:

void taskFunc(int id, void * var)

Parameters:

id Task identifier for the task
var Current value of the task user variable

Return Value:

None

Description:

The task function is the user defined function that will be called each time the task is executed. The parameter id specifies the task identifier assigned to the task when the task was created. This can be used by the task function to access task properties, such as the task user variable, but can be ignored. The parameter var contains the current value of the task variable. The task enable state, scheduling period, or the value of the task variable can be changed by the task function.

To ensure that task scheduling proceeds smoothly, the task function should not take long to execute. It is permitted, but not recommended to call delay() from within the task function. It is also permissible to call Serial functions, such as, Serial.print() from within the task function, but be aware that at 9600 baud, it takes approximately 1ms per character printed.

The actual function name can be any user specified name. The task function is defined in the following way:

void myTaskFunction(int id, void * var)

Personal tools