I have been fighting with sprintf outputting floats. I need to be able to print formatted floating point data. I created a gatekeeper task for the serial port and put sprintf under that task. sprintf can only run within the gatekeeper task.
As a test case I modified the sprintf statement to
sprintf( OutString, "% 06.2f", 23.456 );
and I get " 00.00" in OutString. Any float value returns a zero. Modifying for integers works fine.
I have researched this problem and found the two most common comments are stack size and reentrancy. I have made sure that the stack for the task is large enough, 1500 words are unused on the stack according to the high water mark routines. To test for reentrancy issues, I ensured that the gatekeeper is the highest priority, and even have gone as far as putting sprintf within a critical area and turned off interrupts. Nothing has worked.
This same sprintf line works fine before I start the scheduler, so it is not a library issue.
Then only thing I can find for setting the stack alignment is in portmacro.h as:
#define portBYTE_ALIGNMENT 4
After setting this value to 8 the problems remains unchanged.
Frank,
Thanks, but I am using the CodeSourcery Lite GCC compiler. I am also using Cortex and have looked through the port.c file for something similar, but cannot figure out which function you are suggesting that I modify.
Then only thing I can find for setting the stack alignment is in portmacro.h as:
#define portBYTE_ALIGNMENT 4
After setting this value to 8 the problems remains unchanged.
Frank,
Thanks, but I am using the CodeSourcery Lite GCC compiler. I am also using Cortex and have looked through the port.c file for something similar, but cannot figure out which function you are suggesting that I modify.