float printing

Discussions concerning TrueSTUDIO for STM32 9.0.0 and later versions.

Moderators: Markus Girdland, Mattias Norlander

natilzr
Posts: 3
Joined: Wed Aug 14, 2019 8:09 am

float printing

Postby natilzr » Wed Aug 14, 2019 8:20 am

hello

i cant print float numbers the float number stays empty
float temp;
temp = 24.123;
sprintf((char*)tx_buffer,"n=%f\n",temp);
i have included "string.h" and "stdio.h"

what could be the problem?

kurta999
Posts: 22
Joined: Thu Sep 06, 2018 8:27 am
Location: Slovakia
Contact:

Re: float printing

Postby kurta999 » Wed Aug 14, 2019 10:14 am

I suggest you to use this library, it's better than using -u _printf_float linker script flag. ( “-u _printf_float” in your project properties:
Properties -> C/C++ Build -> Settings -> Linker -> Miscellaneous -> Linker flags )

https://github.com/mpaland/printf

natilzr
Posts: 3
Joined: Wed Aug 14, 2019 8:09 am

Re: float printing

Postby natilzr » Thu Aug 15, 2019 5:25 am

hi
thank you for your answer

i an new with attolic and and didnt understal completly how to use the information you gave .
the miscellaneus in the linker is empty

these are the flags i found in the linker
-mthumb -mcpu=cortex-m0 -T"../STM32F072C8_FLASH.ld" -specs=nosys.specs -static "-Wl,-Map=${BuildArtifactFileBaseName}.map" -Wl,--gc-sections -Wl,--defsym=malloc_getpagesize_P=0x80 -Wl,--start-group -lc -lm -Wl,--end-group -specs=nano.specs

please provide more information how to use your recomendation lib

thank you
nati

natilzr
Posts: 3
Joined: Wed Aug 14, 2019 8:09 am

Re: float printing

Postby natilzr » Thu Aug 15, 2019 5:30 am

hi all

by adding this line :-u _printf_float
to the linker
the float works

-mthumb -mcpu=cortex-m0 -T"../STM32F072C8_FLASH.ld" -specs=nosys.specs -static -u _printf_float "-Wl,-Map=${BuildArtifactFileBaseName}.map" -Wl,--gc-sections -Wl,--defsym=malloc_getpagesize_P=0x80 -Wl,--start-group -lc -lm -Wl,--end-group -specs=nano.specs


thank you


Return to “TrueSTUDIO for STM32 discussions”

Who is online

Users browsing this forum: MSN [Bot] and 3 guests