PRINTF does not print float numbers when %f is used?
I am using PRTINT on RTK1170-EVK M4 core.
Removing CR_INTEGER_PRINTF did not help?
evkmimxrt1170_hello_world_cm4
(void)PRINTF("\r\n[m4]Print float=%f prints nothing?\r\n\n",
3.14);
Example Output:
[m4]Print float=
解決済! 解決策の投稿を見る。
This solution works. Removing CR_INTEGER_PRINTF by itself did NOT help.
In MCUXpresso, right-mouse click project, select Properties, C/C++ Build > Settings, then MCU C Compiler > Preprocessor
if SDK_DEBUGCONSOLE = 0 then PRINTF is directed to printf() in the C library. Code size is larger, but printf will work for floats.
Add SDK_DEBUGCONSOLE_UART to redirect printf output to UART.
SDK_DEBUGCONSOLE=0
SDK_DEBUGCONSOLE_UART
I have similar problems however, when I followed the instructions that were given above, the PRINTF does not even output anything at all.
There is another preprocessor which is PRINTF_FLOAT_ENABLE=0. I changed that to 1 and keep the original settings.
In summary:
1. SDK_DEBUGCONSOLE=1
2. CR_INTEGER_PRINTF (didnt remove)
3. PRINTF_FLOAT_ENABLE=1 (changed from 0 to 1).
And it prints out the float. Anyway, I still need to confirm if that is correct or not.
However, I have a few questions regarding this.
1. Why didnt the SDK keep the preprocessor as 1 by default?
2. Why is the above proposed solution not working for my case?
3. What are those two preprocessors (CR_INTEGER_PRINTF) and (PRINTF_FLOAT_ENABLE=1) doing to be exact? Why do we need them in the first place?
4. Based on my understanding that SDK_DEBUGCONSOLE=1 means using some SDK debug print and not the C printf(), what are the difference between them? Why when I set it 0 and defined the UART preprocessor, I have nothing at all since it should be the standard C printf()?
4. If I am using KEIL and the toolset could be different, do I still need to define all these preprocessor?
Thanks.
Best regards,
Desmond
This solution works. Removing CR_INTEGER_PRINTF by itself did NOT help.
In MCUXpresso, right-mouse click project, select Properties, C/C++ Build > Settings, then MCU C Compiler > Preprocessor
if SDK_DEBUGCONSOLE = 0 then PRINTF is directed to printf() in the C library. Code size is larger, but printf will work for floats.
Add SDK_DEBUGCONSOLE_UART to redirect printf output to UART.
SDK_DEBUGCONSOLE=0
SDK_DEBUGCONSOLE_UART