May 2020
Intermediate to advanced
496 pages
13h 54m
English
Tasks that are created without using the FreeRTOS heap require the programmer to perform allocation for the task's stack and TCB before creating the task. The static version of task creation is xTaskCreateStatic().
The FreeRTOS prototype for xTaskCreateStatic() is as follows:
TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
const char * const pcName,
const uint32_t ulStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
StackType_t * const puxStackBuffer,
StaticTask_t * const pxTaskBuffer );
Let's take a look at how this is used in our example, which creates a task with a statically allocated stack:
static StackType_t RedTaskStack[STACK_SIZE];static StaticTask_t RedTaskTCB;xTaskCreateStatic( RedTask, ...