Page 1 of 1

float printing

Posted: Wed Aug 14, 2019 8:20 am
by natilzr
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?

Re: float printing

Posted: Wed Aug 14, 2019 10:14 am
by kurta999
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

Re: float printing

Posted: Thu Aug 15, 2019 5:25 am
by natilzr
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

Re: float printing

Posted: Thu Aug 15, 2019 5:30 am
by natilzr
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