STM32F407 sprintf with float value

Discussions concerning TrueSTUDIO for STM32 9.0.0 and later versions.

Moderators: Markus Girdland, Mattias Norlander

Posts: 4
Joined: Mon Mar 12, 2018 6:56 am

STM32F407 sprintf with float value

Postby MRomano » Thu Mar 14, 2019 10:03 am

Hi everyone,
I use Atollic TrueSTUDIO® for STM32, Version: 9.3.0 with option USE_HAL_DRIVER

I want to use a sprintf with float value as follow:

char sTemp[50];
float t1 = 25.5;
sprintf(sTemp, "%f;", t1);

but the string always contains the value "0.00000"

I tried both with the Newlib-Nano nano and Newlib standard libraries, adding the "-u _printf_float" flag to the linker and "-mfloat-abi=soft" to the compiler. I also followed other solutions proposed in the forum, but unfortunately I can't get a consistent result.

I tried to compile the code with the USE_STDPERIPH_DRIVER option and the sprintf of a float value works correctly.
I believe the problem appears when using the USE_HAL_DRIVER option.

Please someone can suggest me a solution. I am very worried because I can't solve this problem.

Thanks MRomano

Return to “TrueSTUDIO for STM32 discussions”

Who is online

Users browsing this forum: No registered users and 1 guest