I decided to make the upgrade to FreeRTOS 6.0.0 from FreeRTOS 5.2.0. I have been using sprintf to display floating point values to the serial port. Changing to 6.0.0 I cannot get sprintf to display anything other than zero. The format string works properly, but I only see zeros on the display.
With 5.2.0 I had to play around with stack sizes to get sprintf to work properly, and to make the stack smaller, only one task, the serial port gatekeeper task, is allowed to use sprintf. With 6.0.0, adjusting the stack size makes no difference in the output. I get no error messages from sprintf.
The only difference between the working and the non-working versions are the versions of FreeRTOS. Everything else is the same.
Anybody have any suggestions? (besides "Don’t use sprintf.")
One of the differences between V5.x.x and V6.x.x is the stack byte alignment used on ARM ports. Previously it was set to 4 as this was good enough for everything except some operations on 8 byte data types (like using %f with sprintf). Now it is set to 8 and all 8 byte data type problems should be fixed (?) so it is odd that you report it working before but not now.
Can you look at the stack pointer in the debugger and check that it is indeed 8 byte aligned.
Also, do you have stack overflow detection turned on? Maybe you are simply overflowing a stack.
You could try setting portBYTE_ALIGNMENT to 4 (its old value) in portmacro.h to see if that makes it work again. As 8 is a multiple of 4 I would not have thought it would make any difference, unless I have made a mistake somewhere else.
Could you try setting a break point on the very first line of the task that calls sprintf(). Depending on the debugger being used that will often be on the opening bracket of the function. For example:
void vATaskFunction( void *pv )
{ /* Place break point here, before variable definitions. */
int x, y, etc;
Alternatively view the code in assembly, and add a break point on the first assembly line. The important thing is that the break point is hit before the function prologue that sets up the stack and frame pointers is executed.
What is the stack pointer value when that break point is hit?
Hi again. It looks like I might have messed up because of the ‘decrement before’ behaviour. I would be grateful if you could try the following:
<ol>
<li> Open up port.c from the Source/portable//CM3 directory.
<li> Add the line "pxTopOfStack-;" to the top of the function pxPortInitialiseStack().
</ol>
Using markdown syntax in the reply is fine when viewed in the preview window, but does not work when viewed in the forum or in the emails of posts I received. This forum seems totally screwy at the moment.