...
In order to print floats from other tasks, it’s necessary to align the stack of the appropriate task. In the simplest case, when the task stack is declared separately, it’s straightforward to specify the data alignment.
In general, it’s possible to align the stack of any task using the data_alignment
pragma, as shown below for an arbitrary stack:
Code Block | ||
---|---|---|
| ||
// app variables
#pragma data_alignment = 8
OS_STK myTaskStack[STACK_SIZE];
|
Otherwise, if the stack is declared in a structure containing several fields, we can use the same approach as demonstrated above, moving the task stack to the beginning of the structure and aligning the whole structure.
Code Block | ||
---|---|---|
| ||
// prototypesapp staticvariables void myTask(void* unused); void myStackInit() { // .. called from some init function .. // create the task osErr = OSTaskCreateExt( myTask, (void *) 0, (OS_STK*) (&typedef struct { OS_STK myTaskStack[STACK_SIZE-1]),; ... PRIORITY, PRIORITY, (OS_STK*) &myTaskStack, STACK_SIZE, (void *) 0, OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR ); } |
...
} my_task_vars_t;
#pragma data_alignment = 8
static my_task_vars_t my_task_v; |
See also http://supp.iar.com/Support/?Note=85413.