Modification of ENCODING ERROR problem of serial printf output floating-point data (based on STM32CubeIDE)

  Serial port printing is a very common and important debugging method for embedded development. When using STM32CudeIDE for development, I encountered the problem of serial output encoding error. At the beginning, I did not realize that it was a problem when printing floating point numbers. Other data is normal, but with hindsight, it turned out to be a pot of floating-point data, as shown in the following figure:
Insert picture description here

**

How to solve it?

**
Step1 : Open your project in STM32CubeIDE, right-click the project name, and select Properties;
Insert picture description here
Step2 : C/C++ Build -> Settings -> MCU GCC Linker -> Miscellaneous
Insert picture description here

Step 3 : Add Other flags -u_printf_float
Insert picture description here
Final : After adding it, recompile, Now It's OK to use.
Insert picture description here
Appendix:
Reference blog post- https : //blog.csdn.net/qq_42980638/article/details/98359026

Guess you like

Origin blog.csdn.net/qq_33475105/article/details/108438710