FloatToStr issue for Mikroe-M4 (STM32F415)
Posted: 12 May 2021 11:12
Hi community !!!
I have strange issue for my STM32F415.
The functions FloatToStr returns vrong value if the divisor value between 0.5 and 1
For example -
var
A_str:String[30];
B:single;
begin
B:=0.65;
FloatToStr(B,A_str);
UART1_write_text(A_str);
end;
My uart decoder in oscilloscope , UART sniffer in another PC , NEXTION display , all those devices show "1.35000" instead "0.65".
Built in debugger show A_string correctly "0.65";
This is table of returns value of FloatTostr function.
Input float: returned value:
0.1..0.5 working normally.
0.51 "1.49000"
0.65 "1.35000"
0.80 "1.20000"
0.99 "1.01000"
1 "0.00000"
1.1 "1.1"
1.2 "1.2"
...
1.5 "2.5'
1.6 "2.4"
and etc..
I checked this bug twice. Unternal debugger show correctly convertations but the compiled code during working in the STM32 showing incorrectly conversion resultat.
Please tell me any solutions because i not sure that my custom Floattostr function will worling correctly in my all onther projects in future.
I have strange issue for my STM32F415.
The functions FloatToStr returns vrong value if the divisor value between 0.5 and 1
For example -
var
A_str:String[30];
B:single;
begin
B:=0.65;
FloatToStr(B,A_str);
UART1_write_text(A_str);
end;
My uart decoder in oscilloscope , UART sniffer in another PC , NEXTION display , all those devices show "1.35000" instead "0.65".
Built in debugger show A_string correctly "0.65";
This is table of returns value of FloatTostr function.
Input float: returned value:
0.1..0.5 working normally.
0.51 "1.49000"
0.65 "1.35000"
0.80 "1.20000"
0.99 "1.01000"
1 "0.00000"
1.1 "1.1"
1.2 "1.2"
...
1.5 "2.5'
1.6 "2.4"
and etc..
I checked this bug twice. Unternal debugger show correctly convertations but the compiled code during working in the STM32 showing incorrectly conversion resultat.
Please tell me any solutions because i not sure that my custom Floattostr function will worling correctly in my all onther projects in future.