Question
sprintf doesn't work well to show float (I already added -u _printf_float in linker options)
Hi all,
I have a problem to show float numbers via sprintf, I'm working with STM32F334
I did a program to print via serial the voltage read from ADC, in float format like %4.2f, the problem is that the first time the sprintf generate a valid string with decimal separator, but the next iterations not.
I followed the tip recommended for @Hae Ryon Jung in this entry of forum, but I didn't get a good result
Any idea?
This is the code:
adcVal = HAL_ADC_GetValue(&hadc1);
adcRes = adcVal*3.3/4096;
sprintf(buffTmp, "[%d]ADC %d %4.2f V\n\r", (int) counter, (int)adcVal, adcRes);This is the output:
[0]ADC 2531 2.04 V
[1]ADC 2493 204 V
[2]ADC 2495 204 VThanks for your support
Regards
Jordi
