Good morning.
I'm using the sprintf function but it doesn't work with float and double type.
It works properly only with integer.
I found a lot of information on this problem, but referred to the codewarrior ide.
How it's possible to solve this in the kinetis dev system ?
Thanks.
Claudio
I did same as matherin,
but not getting float printing, I getting error like this,
plz anyone clarify this doubt.
Hi Syed,
What processor are you using? Looking at the errors it seems like KL03.
The above post were asking for printf/scanf with floating point support. Is that what you want too?
If yes attached is an example project for the FRDM-KL03Z.
Note that KL03 on the Freedom board is limited to 32KByte flash and very limited to 2KByte of SRAM.
Because of that I had to increase the compiler optimization to get the linker to work.
Regards,
David
David sir,
Thanks for your reply.
Actually I am a beginner, and yes you are right, I am using KL03 processor.
And I don't know about processor expert. I am trying to learn with demo codes provided with KDS3.0.0 IDE. when I am trying to print the float value like,
float a=2.4;
PRINTF("%f",a);
I am getting output as ' f ' only, so I searched on forum and enabled the option -u_printf_float with the following:
Properties -> C/C++ build -> Settings -> Cross ARM C Linker -> Miscellaneous -> Use float with nano printf
But, no change in the behavior of printf.
I will be thankful to you if you solve my problem
Hi Syed,
Please open your Properties of your project and add the following SCANF_FLOAT_ENABLE and PRINTF_FLOAT_ENABLE....recompile and run again.
Regards,
David
Claudio,
Did you ever get this to work? I cannot get the approach described in the Erich Styger article referenced above to work because his comments are referencing newlib-nano, not newlib. Any help would be appreciated.
Thanks,
Larry
Semihosting (and printf()) depends on the library used.
Have a look at
Semihosting with GNU ARM Embedded (Launchpad) and Kinetis Design Studio | MCU on Eclipse
Do not forget to use the -specs=rdimon.specs linker option.
I hope this helps,
Erich
Hi Claudio,
Please take a look at the following post created by our colleague Erich Styger, it explains how to use printf() and scanf() with floating point:
printf() and scanf() with GNU ARM Libraries | MCU on Eclipse
Hope it helps.
Best regards!
Carlos
Hello,
I have add -u _printf_float to the linker options to enable float/double support to printf/sprintf(), but still can not work with float, any other configuarion needed?