2018-06-24 10:11 PM
Hi All,
I'd like to print float value with printf.
when I tried, printf showed blank for float value.
would you please let me know how to set TrueStudio for printing float value with printf ?
I'm using STM32F103RF.
Thanks in advance.
#floatSolved! Go to Solution.
2018-06-25 12:51 AM
Thanks to you all,
I could print float value by adding '-u _printf_float' as you said.
following captureis project property , add it like this at Settings -> C- Linker -> Command: arm-atolic-eabi-gcc -u _printf_float
2018-06-24 10:34 PM
I don't know TrueStudio in detail, but I suspect their printf implementation does not support float/double arguments and formatting.
This is quite common, to keep code sizes small. You can check the documentation, or the source code, if available.
2018-06-24 11:06 PM
Have you tried to add
-u _printf_float to your linker flags?
2018-06-24 11:23 PM
my linker option is as follows.
-mthumb -mcpu=cortex-m3 -T'../STM32F103RF_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
would you let me know how to add -u __printf_float to linker option ?
2018-06-25 12:51 AM
Thanks to you all,
I could print float value by adding '-u _printf_float' as you said.
following captureis project property , add it like this at Settings -> C- Linker -> Command: arm-atolic-eabi-gcc -u _printf_float
2018-06-25 01:39 AM
Sorry can't help you. I'm using Eclipse.
2018-06-25 01:46 AM
my linker option is as follows.
-mthumb -mcpu=cortex-m3 -T'../STM32F103RF_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
The nano-lib version has definitely no printf float support.
2018-06-25 02:34 AM
please let me know how to change it, in TrueStudio
2018-07-31 08:29 AM
I want use sprintf for float with STM32H7. If I use Newlib-nano unter C/C++ Build -> Settings-> ToolSetting -> General it works with integer and without float. With Newlib standard I get an error in startup-script at Line 10.
"Failure at line: 10 in 'Target Software startup Skript'. Please edit the debug configuration settings.
Error writing data to flash"
With "-u __printf_float" in C-Linker->Miscellaneous->Other options with Newlib-nano I get the same error.
# Set flash parallelism mode to 32, 16, or 8 bit when using STM32 F2/F4 microcontrollers
# 2=32 bit, 1=16 bit and 0=8 bit parallelism mode
# monitor flash set_parallelism_mode 2
# Set character encoding
set host-charset CP1252
set target-charset CP1252
# Load the program executable
load
# Enable Debug connection in low power modes (DBGMCU->CR)
set *0xE0042004 = (*0xE0042004) | 0x7
# Set a breakpoint at main().
tbreak main
# Reset to known state
monitor reset
# Run to the breakpoint.
continue
2018-07-31 02:09 PM
If there are forces to step away from the general path.