Loading...
 

System Workbench for STM32


Need Float output for printf

I have read that the floating point outputs for printf is turned off by default. How do I turn it on?

Hello,

I know that this thread is one year old, but to give an answer for other people that are looking for the answer, I will give it.

By default the float support is disabled. To enable it, add the linker flag: “-u _printf_float” in your project properties:
Properties -> C/C++ Build -> Settings -> MCU GCC Linker -> Miscellaneous -> Linker flags

Argentina

Hello, I’m asking you directly because you seem to know your way around OpenSTM32.

I’ve added the configuration that you posted, and it worked great, but compiling memory took up an extra 15kByte or so of memory just so the printf + float would work.

Do you know of any workaround that takes up less memory? Or I should write my own code to printf float numbers to save rom memory?

Regards,

Arielo


Very helpful @rreignier! I was fighting with printing floats for a while before I ran across this. Making my own “Printfloat” ended up being less accurate than enabling that flag. I included a screenshot to go along with your answer.

Thank you very much rreignier. Useful contribution!!! Thx

Hello!
There was the same need as in the topic starter. After installing this flag, the output stopped working at all. What is wrong?


 

Newest Forum Posts

  1. Problem programming chip by JimELi, 2019-03-25 21:26
  2. CubeMT code, generated for SW4STM32 by market14, 2019-03-25 03:57
  3. Problem verifing and downloading code by strohmas, 2019-03-24 23:16
  4. Nucleo-144 TCP Problems by mklee, 2019-03-22 19:25
  5. CubeMX function pack development by ajcurtis84, 2019-03-22 18:59
  6. STM32CubeMX LWIP not working by leflingue, 2019-03-22 12:22
  7. STM32CubeMX LWIP not working by matsjuhlin, 2019-03-22 09:13
  8. STM32F746-Discovery by stanandrzej, 2019-03-21 12:41
  9. System Workbench takes up to five minutes to load by Servant, 2019-03-21 02:39
  10. How to use multiple ST boards simultaneously by Kevarek, 2019-03-20 19:21

Last-Modified Blogs