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:
**
How to solve it?
**
Step1 : Open your project in STM32CubeIDE, right-click the project name, and select Properties;
Step2 : C/C++ Build -> Settings -> MCU GCC Linker -> Miscellaneous
Step 3 : Add Other flags -u_printf_float
Final : After adding it, recompile, Now It's OK to use.
Appendix:
Reference blog post- https : //blog.csdn.net/qq_42980638/article/details/98359026