cancel
Showing results for 
Search instead for 
Did you mean: 

Floating and printf not working

Aurélien f
Senior
Posted on May 22, 2017 at 14:13

Hello,

I would like to print floating variable with printf but it is not working. i'm using a stm32l073 MCU that does not have any FPU. I'm activating 

-u _printf_float  

in my llinker but it doest not change anything. All other type are working well. If someone knows how to solve my issue, please feel free to share your solution.

Best regards,

Aurélien

4 REPLIES 4
AvaTar
Lead
Posted on May 22, 2017 at 14:30

The FPU is not really helpful for printf(), i.e. generating an ASCII string from a float/double number.

I guess you have the 'wrong' library. Libraries optimized for size often come with a scaled-down printf/scanf, which does not support the float format.

Check with your toolchain and project settings.

john doe
Lead
Posted on May 22, 2017 at 14:32

remove nano.specs from your linker options

Aurélien f
Senior
Posted on May 24, 2017 at 14:26

Hello

@john doe : i removed 'nano.specs' from linker option but it does not  have changed anything in spite of that, now, the MCU is no longer raising an exception, but it is printing wrong characters. When i let 'nano.specs' + '

-u _printf_float',

the MCU raises a hardfault exception.

@AvaTar : i will check my toolchain, i'm maybe missing something,  

Posted on May 24, 2017 at 15:18

The 'nano.specs' thing is toolchain specific.

But the idea is basically correct, the 'nanolib' version of the clib uses to have a printf without floating point format support.