17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Each RTOS task is specified as a function that has no parameters and no return. The #TASK<br />

directive is needed just before each RTOS task to enable the compiler to tell which functions are<br />

RTOS tasks. An RTOS task cannot be called directly like a regular function can.<br />

Syntax:<br />

Elements:<br />

#TASK (options)<br />

options are separated by comma and may be:<br />

rate=time<br />

Where time is a number followed by s, ms, us, or ns. This specifies how<br />

often the task will execute.<br />

max=time<br />

Where time is a number followed by s, ms, us, or ns. This specifies the<br />

budgeted time for this task.<br />

queue=bytes<br />

Specifies how many bytes to allocate for this task's incoming messages.<br />

The default value is 0.<br />

enabled=value<br />

Specifies whether a task is enabled or disabled by rtos_run( ).<br />

True for enabled, false for disabled. The default value is enabled.<br />

Purpose:<br />

This directive tells the compiler that the following function is an RTOS<br />

task.<br />

The rate option is used to specify how often the task should execute.<br />

This must be a multiple of the minor_cycle option if one is specified in the<br />

#USE RTOS directive.<br />

The max option is used to specify how much processor time a task will<br />

use in one execution of the task. The time specified in max must be<br />

equal to or less than the time specified in the minor_cycle option of the<br />

#USE RTOS directive before the project will compile successfully. The<br />

compiler does not have a way to enforce this limit on processor time, so<br />

a programmer must be careful with how much processor time a task<br />

uses for execution. This option does not need to be specified.<br />

The queue option is used to specify the number of bytes to be reserved<br />

for the task to receive messages from other tasks or functions. The<br />

default queue value is 0.<br />

Examples:<br />

Also See:<br />

#task(rate=1s, max=20ms, queue=5)<br />

#USE RTOS<br />

130

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!