Hello,
I am using KSDK 1.1.0 with MQX and Processor Expert. Using printf() usually works fine, but I cannot make printf to print float/double values. For the code
float val = 1.234;
printf("Value = %f unit\n", val);
the output is
Value = f
I guess the reason is because printf() does not support float with the default KSDK settings for MQX, so I added "#define MQX_INCLUDE_FLOATING_POINT_IO 1" to mqx_sdk_config.h but the behavior is still the same.
Any hints what I am doing wrong?
Regards
Matthias
解決済! 解決策の投稿を見る。
Hi Matthias,
I have reproduced your finding and have submitted a trouble ticket to our MQX KSDK team.
Documentation should be updated and we should have a master location to define the STD_FP_IO option/capability.
My workaround...
Change std_prv.h to following:
#ifndef STD_FP_IO | //DES added #ifndef | |
#define STD_FP_IO 0 |
#endif
And in the project Properties...add Defined for "STD_FP_IO=1":
Regards,
David
I just tried this - went to mqx_stdlib_Source/include/std_prv.h and set "#define STD_FP_IO 1" (I'll do the ifndef once this works).
I recompiled the KSDK libraries: mqx_stdlib_frdmk64f, ksdk_mqx_lib, ksdk_platform_lib_K64F12, and mqx_frdmk64f and did a simple printf w/ floating point.
I get MQX_UNHANDLED_INTERRUPT (0x0041) exception.
Setting it back to 0, printf works as expected.
What am I missing?
Thanks,
-Raj
Silly mistake - I was getting a stack over flow because stack size was set too small for printf floating point support. Once I increased stack, floating point printing worked. FYI, the -u _printf_float made no difference, just Matthias/David's comment to define STD_FP_IO to 1.
Thanks,
-Raj
Hi I am getting same float printing problem in kinetis design studio 3.0.0 how to solve this?
A easyer way is:
Under Project Settings -> C/C++ Build -> Settings -> Tool Settings -> Miscellaneous
enable the Checkbox: "Use float with nano printf".
Hi Matthias,
are you using KDS/GNU libraries? If so, have you added
-u _printf_float
to the linker options?
(see printf() and scanf() with GNU ARM Libraries | MCU on Eclipse).
I hope this helps,
Erich
Hello Erich,
thanks for the quick reply. I am using the MQX libraries that are included in KSDK. I have seen your post on mcuoneclipse.com (which helped me many times before :-)) and I have tried -u _printf_float in the linker options without success (I guess this option does not apply for KSDK libraries). I think the problem lies somewhere in the configuration of the KSDK/MQX libraries.
Regards
Matthias
I found a soultion now, but I am not very comfortable with it yet:
In the KSDK source code, there is a file "std_prv.h" where STD_FP_IO is defined. Setting this define to "1", printf() works with float. But as said, I am not comfortable with changing a file in the KSDK source code.
Hi Matthias,
I have reproduced your finding and have submitted a trouble ticket to our MQX KSDK team.
Documentation should be updated and we should have a master location to define the STD_FP_IO option/capability.
My workaround...
Change std_prv.h to following:
#ifndef STD_FP_IO | //DES added #ifndef | |
#define STD_FP_IO 0 |
#endif
And in the project Properties...add Defined for "STD_FP_IO=1":
Regards,
David
Hi David,
So is it applicable for CW 10.6 with MCU MKE06Z as well? I have posted similar question about printf(%f) at here https://community.nxp.com/thread/438758
Thanks...
Just thought I'd add my $0.02 worth for anybody else in this situation. I'm using KSDK 1.2.0 with Processor Expert in KDS 3.0 to create code to be built with IAR Embedded Workbench. I've added the MQX component to my project and chosen the standard MQX instead of MQX Lite. I found that the right place to put the define for STD_FP_IO = 1 is in the Component Inspector for MQX, in the User settings Definitions dialog:
Also be sure to make the change to std_prv.h in the KDS project. If you change any of the generated files outside the Processor Expert environment (i.e. you edit them in IAR Workbench) you'll get errors from Processor Expert the next time you try to generate code.