Floating point operations in the thread
-
Include the following function at the beginning of each task, which uses floating-point calculations:
portTASK_USES_FLOATING_POINT();
Printing numbers
- Standard C function printf() does not work in freeRTOS. Use xil_printf() instead.
- xil_printf() does not support printing float or double. To print double with constant precision, use the following function (or adapt it to your needs):
void printDouble8(double fval) { double fval2=fval; int intergerPart, fractionalPart; if (fval2>INT32_MAX || fval2<= INT32_MIN) { xil_printf("XXX.XXXXXXXX"); return; } int sign=0; if (fval2<0) sign = 1; fval2 = fabs(fval2); intergerPart = fval2; fractionalPart = (fval2 - intergerPart) * 100000000; if (sign) xil_printf("-"); xil_printf("%d.%08d", intergerPart, fractionalPart); }
Quitting task
- Most of tasks in freeRTOS should contain infinte loop, which never quits.
- However, if you need to quit a task, add the function vTaskDelete( ) at the end.