I'm using KDS 3.2.0 with the MKE02Z64VLC4 processor and need to use the sprintf/snprintf functions with the float specifier %f. However, it will not work. It shows nothing. I some other posts that have work-around suggestions and various things to try. I just want to know what is the correct/recommended way of enabling sprintf/snprintf to use floating point data types for the format specifier.
Thanks,
Bill
解決済! 解決策の投稿を見る。
Hi Bill,
have you added
-u _printf_float
?
See https://mcuoneclipse.com/2014/07/11/printf-and-scanf-with-gnu-arm-libraries/
I hope this helps,
Erich
That worked - but I had to add it as (add the equal sign):
-u=_printf_float
And then select the checkbox in the linker options to adding support for float in printf.
Thanks!
Hi Bill,
have you added
-u _printf_float
?
See https://mcuoneclipse.com/2014/07/11/printf-and-scanf-with-gnu-arm-libraries/
I hope this helps,
Erich
This is still not working for me, and after an exhaustive search I have found no solution to get this working.
I am also having this problem, my program crashes on the first sprintf that uses a double argument.
I have checked the box "Use float with nano printf(-u _printf_float)", and it behaves the same way.
I am using MK61FN1M0VMJ12 on KDS 3.2.
This is after the program working great with no issues on Codewarrior.
So I am in the same boat as others, running out of ideas to fix this.
If it is crashing: can you increase the heap and stack size? printf() uses more stack and potentially heap memory (depending on the library).
Some more info - This is what shows in the console when the system crashes on the sprintf with a float.
BusFault: An imprecise (asynchronous) data access error has occurred.
HardFault: A fault has been escalated to a hard fault.
I am having trouble finding a define for the heap, I used this thread for assistance.
Changing Heap and Stack Size for NXP Kinetis SDK V2.0 gcc Projects | MCU on Eclipse
The linker file has nothing mentioning the heap.
Using the MQX Stack Usage view in KDS, it appears that none of my tasks are running over. This is pretty quick upon startup, so there are only a few tasks running at the point it crashes.