I am working on a project in MCUXpresso that was originally written in code warrior. I am having difficulty using a sprintf() function and the problem seems to be with MCUXpresso. I have checked that I am using the original compiler and I am using the Redlib semihost C library. Below is the code:
char tString[50];
float current = 1.2;
sprintf(tString, "%3.0f",current);
After stepping through this code, the first three entries of tString are 32 ' '. What could be causing this issue?
Solved! Go to Solution.
I see you still have that CR_INTEGER_PRINTF in the list of defines. Remove it.
I hope this helps,
Erich
Are you using RedLib (the default)?
If yes, see https://community.nxp.com/docs/DOC-342727
I hope this helps,
Erich
I am using RedLib, I followed the instructions in the article you have referenced and when I opened that window the only directive from the article was PRINTF_FLOAT_ENABLE=0. I modified the directives as seen below and this has still not solved the issue. Additionally, I have included a snip of the tString after sprintf is called.
I see you still have that CR_INTEGER_PRINTF in the list of defines. Remove it.
I hope this helps,
Erich
This seems to have solved the issue, thank you. I additionally found that it works using the NewLibNano library and selecting enable printf float and enable scanf float in the Managed Linker Script.