hi,
i just installed KDS v1.1 and trying to use sprintf() with floating point numbers on the Freedom KL25z board. I added the -u _printf_float to the linker flags but when i try to debug my program stops. I am a newb to this stuff and have been reading as much as i can to try to fix it but am at a loss.
here is a screenshot from the debugger
thanks
Solved! Go to Solution.
Hi Chris,
the problem is that sprintf() requires a heap for the newlib-nano implementation of that particular version of newlib-nano included in KDS.
This is already mentioned in the release notes (not particularly in the context of sprintf(), but obviously this applies for this case too).
I see that you are using a Processor Expert project, so increase the heap size to at least 0x400 (see below, and see Switching between ‘tabs’ and ‘no-tabs’ UI in Processor Expert | MCU on Eclipse if you want the same view).
As a reference, I have attached my test project, where I was able to reproduce your problem with a heap size of zero, and then it worked when I increased the heap for the newlib-nano.
I hope this clarifies the problem, and with this you can solve it.
Erich
Hi Chris,
the problem is that sprintf() requires a heap for the newlib-nano implementation of that particular version of newlib-nano included in KDS.
This is already mentioned in the release notes (not particularly in the context of sprintf(), but obviously this applies for this case too).
I see that you are using a Processor Expert project, so increase the heap size to at least 0x400 (see below, and see Switching between ‘tabs’ and ‘no-tabs’ UI in Processor Expert | MCU on Eclipse if you want the same view).
As a reference, I have attached my test project, where I was able to reproduce your problem with a heap size of zero, and then it worked when I increased the heap for the newlib-nano.
I hope this clarifies the problem, and with this you can solve it.
Erich
Thanks, i did read about changing the heap setting and i thought i did so. i went back and did it again and it works.
Good morning Chris & Erich.
And if you don't use PE ? How it's possible to fix it ?
With an integer number sprintf works perfectly. With float or double it returns "" and no coversion is done.
Thanks a lot.
Claudio
Hi Claudio,
see printf() and scanf() with GNU ARM Libraries | MCU...
You need to add
-u _printf_float
to the linker options to enable float/double support to printf/sprintf()
Erich