I have an issue where sprintf sometimes printing an unexpected string. The call: sprintf(str_my_string, "%#.1f", 0.0); is made from inside a function called from a task. Most of the time, the expected string is printed (0.0) and it only occurs every minute or two. This issue started occurring after adding the FreeRTos to our existing project and has never happened before. What might cause this issue? How should I go about troubleshooting this?
Thanks for you help
I did some more troubleshooting and found that it only occurs when I have a 1ms timer interrupt enabled and that if I let the same code run in a while loop, it happens so often (seems to be more than 2 times a second). Then, I switched from the version that we are using V5.0.2 to the newer version V7.3.0 and it works fine so far.
I am still not sure what caused the issue but I am starting to think that it has to do with saving and restoring the context although the save/restore context assembly macros of the two versions are the same.
I am still concerned that somehow the new version is masking other problems somewhere else.
I will keep working on it.
Problem solved!!! It was caused by a bug in version V5.0.2 that was not handling memory alignment properly in xCreateTask function. Version V7.3.0 works.
V5.0.2 create task function does this:
pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( unsigned short ) 1 );
It should also do this:
pxTopOfStack = ( portSTACK_TYPE * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK ) );
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.