cancel
Showing results for 
Search instead for 
Did you mean: 

The float formatting support is not enabled

Fahd
Associate II

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);

 

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief III

Your error isnt about float. You compile bigger code as flash... try change optimize level or better not use float.

View solution in original post

4 REPLIES 4
MM..1
Chief III

Your error isnt about float. You compile bigger code as flash... try change optimize level or better not use float.

Fahd
Associate II

Thanks after changing optimizition level it works. Ididn't know float take so much space.

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.

NEdom.1
Associate III

Use printf in C/C++ very carefully in embedded software. The printf family functions could be very dirty in memory access and bloated in code size.