2026-01-28 7:49 AM - edited 2026-01-28 7:52 AM
Extension 3.7.0
st-arm-clang 19.1.6+st.10
Hello,
I am using CubeIDE für VSCode.
I write programs for the STM32F756ZGTx. I have set ST Arm Clang as the compiler in CubeMX. Redirecting the output (printf()) via the serial debug interface is possible without any problems. When I try to output float or double values with printf(), I get some weird results.
printf() with integer float/double yields correct results for integer float/double wrong
printf() with float/double integer always leads to incorrect results
I repeated the experiment for double variables. The same problem occurs here as well.
#include "main.h"
#include <stdio.h>
extern UART_HandleTypeDef huart3;
double floatVar = 1.1f;
void mainThread(void)
{
printf("\r\n\nHello from Nucleo F756 - float Test\r\n"
"-----------------------------------\r\n");
for(;;){
printf("Float value: %f - Integer %u\r\n", floatVar, (unsigned int) floatVar);
printf("Integer %8u - Float value: %f\r\n", (unsigned int) floatVar, floatVar);
HAL_Delay(500);
floatVar += 1.0f;
}
}
int __io_putchar(int ch) {
HAL_UART_Transmit(&huart3, (uint8_t*) &ch, 1, 100);
return ch;
}
Variable type float
Hello from Nucleo F756 - float Test
-----------------------------------
Float value: 1.887500 - Integer 2684354560
Integer 1 - Float value: -0.000000
Float value: 2.012500 - Integer 3221225472
Integer 2 - Float value: -2.000000
Float value: 2.137500 - Integer 3221225472
Integer 3 - Float value: -2.000000
Float value: 2.256250 - Integer 1610612736
Integer 4 - Float value: 36893490000000000000.000000
Float value: 2.318750 - Integer 1610612736
Integer 5 - Float value: 36893490000000000000.000000
Float value: 2.381250 - Integer 1610612736
Integer 6 - Float value: 36893490000000000000.000000
Float value: 2.443750 - Integer 1610612736
Integer 7 - Float value: 36893490000000000000.000000
Variable type double
Hello from Nucleo F756 - float Test
-----------------------------------
Float value: 0.000000 - Integer 2684354560
Integer 1 - Float value: -0.000000
Float value: 0.000000 - Integer 3489660928
Integer 2 - Float value: -8589935000.000000
Float value: 0.000000 - Integer 3489660928
Integer 3 - Float value: -8589935000.000000
Float value: 0.000000 - Integer 1744830464
Integer 4 - Float value: 2417851600000000000000000.000000
Float value: 0.000000 - Integer 1744830464
Integer 5 - Float value: 2417851600000000000000000.000000
Float value: 0.000000 - Integer 1744830464
Integer 6 - Float value: 2417851600000000000000000.000000
Float value: 0.000000 - Integer 1744830464
Integer Please find enclosed the project.
What am I doing wrong? Is a linker or compiler option missing?
Thanks