Книга: Advanced PIC Microcontroller Projects in C

10.5.2 Declaring a Task

10.5.2 Declaring a Task

A task is declared just like any other C function, but tasks in a multi-tasking application do not have any arguments and do not return any values. Before a task is declared, a #task preprocessor command is needed to specify the task options. The format of this preprocessor command is:

#task(rate=n, max=m, queue=p)

where rate specifies how often the task should be called. The number specified must be followed by s, ms, us, or ns. max specifies how much processor time a task will use in one execution of the task. The time specified here must be equal to or less than the time specified by minor_cycle. queue is optional and if present specifies the number of bytes to be reserved for the task to receive messages from other tasks. The default value is 0.

In the following example, a task called my_ticks is every 20ms and is expected to use no more than 100ms of processor time. This task is specified with no queue option:

#task(rate=20ms, max=100ms)
void my_ticks() {
 ...........
 ...........
}

Оглавление книги

Оглавление статьи/книги

Генерация: 1.061. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз