Problem with sprintf and float numbers
First of all, Merry Christmas to everybody.
I have a problem using sprintf with float numbers and would appreciate if someone could help me.
Using sprintf with float numbers doesn’t work at all. I have search into the forum and used all hints that I found but without any success.
This post http://www.openstm32.org/tiki-view_forum_thread.php?comments_parentId=2108 says that it is needed these linker flags “-specs=nosys.specs -specs=nano.specs -u _printf_float”. In this other post http://www.openstm32.org/tiki-view_forum_thread.php?comments_parentId=1838
it is sugested to use syscall.c file or “-specs=nosys.specs” linker flag. This post http://www.openstm32.org/tiki-view_forum_thread.php?comments_parentId=954
says to enable float support adding the linker flag: “-u _printf_float”.
With all this information I have tried all possible combinations of linker flags with different results:
Using sprintf(BufferTx,”Welcome %d %g %s\r\n”, 15, 16.56789, “hello”);
I have obtained these results:
-specs=nosys.specs -specs=nano.specs -u _printf_float
Jumps to HardFault_Handler.
-specs=nosys.specs -u _printf_float
Only prints “Welcome 15” and program stops working properly.
-specs=nosys.specs
Only prints “Welcome 15” and program stops working properly.
-u _printf_float
Jumps to HardFault_Handler.
-specs=nosys.specs -specs=nano.specs
Doesn’t print any float number at all but program still works properly.
-specs=nano.specs
Doesn’t print any float number at all but program still works properly.
-specs=nano.specs -u _printf_float
Doesn’t print any float number at all but program still works properly.
without any of these linker flags
Only prints “Welcome 15” and program stops working properly.
I have update my system to
C/C++ Debugging Tools for MCU Version: 1.11.2.201612060912
C/C++ Embedded Development Tools for MCU Version: 1.12.0.201612060912
Linker Script Editor Version: 1.11.0.201611241417
C/C++ Debugging Tools for MCU Version: 1.0.6.201612060912
but the problem persists.
Could you give me some hints to solve this problem?.
Thanks in advance.
PD: I forgot to say that the project was generated with STM32CubeMX for STM32L4Discovery board (STM32L476VG CPU) using HAL, FreeRTOS, 3 tasks and 1 USART.