2024-11-25 11:32 AM
Hello All,
I am getting this error while compiling the project " The float formatting support is not enabled ".
I have checked use float with "printf from new lib-nano" in MCU/MPU settings save and recompile the problem didn't go!!
I have added manually "-u_printf_float" in MCU/MPU GCC linker with no success.
I am using the latest version of stm32cubeide 1.16.1 the MCU is stm32g031f6p6.
my code in while loop:
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1, 20);
voltage = (HAL_ADC_GetValue(&hadc1)/4096) * 3.3f;
printf("Voltage = %0.2f\n", voltage);
HAL_Delay(1000);
Solved! Go to Solution.
2024-11-25 11:59 AM
Your error isnt about float. You compile bigger code as flash... try change optimize level or better not use float.
2024-11-25 11:59 AM
Your error isnt about float. You compile bigger code as flash... try change optimize level or better not use float.
2024-11-25 11:45 PM
Thanks after changing optimizition level it works. Ididn't know float take so much space.
2024-11-25 11:55 PM
The STM32Gxx MCUs are Cortex M0/M0+.
They have no FPU, and thus no floating point instructions.
Everything needs to be emulated.
If not absolutely necessary, avoid float - even float constants.
voltage = (HAL_ADC_GetValue(&hadc1)/4096) * 3.3f;
printf("Voltage = %0.2f\n", voltage);
Things like this can easily be done with scaled integer maths.
The resulting code is an order of magnitude smaller.