Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


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=2108Question 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=1838Question 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=954Question 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.

This topic can be closed. It was a stack overflow problem.
The stack size (512 bytes) of FreeRTOS task was not enough to call sprintf function. This is surprising, at least for me, because the task does nothing but call sprintf function.
Thanks.
jmpardo.

Thank you!
Solved my issue as well!

Ukraine

cool!!! had this trouble! resolved this as adds more stack size for task with float point processing.
Tnx!


Thank you, your answer helped me.

 

Newest Forum Posts

  1. Монтаж камина с грилем в Москве - установка и барбекю by KpddomErorb, 2025-05-10 18:28
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs