Hi Guys,
I have problem converting a real number to string with the conversion lib.
'FloatToStr(temperatur, temp_text);'
Temperatur is REAL and temp_text is array[23] of char;
In the debugger, the value in the variable before execute FloatToStr is: 2.364854E + 001.
After conversion the value in the variable is: 2.595782E-006.
That can't be right. What am I doing wrong.
Can someone help me.
Greetings micha
Problem with conversion FloatToString
Re: Problem with conversion FloatToString
Hi,
Can you please attach the code snippet that demonstrates this issue ?
Regards,
Filip.
Can you please attach the code snippet that demonstrates this issue ?
Regards,
Filip.
Re: Problem with conversion FloatToString
Hi filip,
I have minimized the program so far that the problem can be reproduced.
If the variable temperature and temperature_text are declared global, the problems arise.
You can see that in the debugger (the variables in the watch list).
However, if the variables are declared in the function and not global, the problem does not occur.
Regards,
micha
I have minimized the program so far that the problem can be reproduced.
If the variable temperature and temperature_text are declared global, the problems arise.
You can see that in the debugger (the variables in the watch list).
However, if the variables are declared in the function and not global, the problem does not occur.
Regards,
micha
Code: Select all
program MyProject;
//Test configuration:
// MCU: STM32F401RE
// Dev.Board: NUCLEO-F401RE
{ Declarations section }
var
x : byte;
//
temperatur : real;
temperatur_text : array[15] of char;
//-----------------------------------------------------------
Function werte():byte;
//var
// temperatur : real;
// temperatur_text : array[15] of char;
begin
temperatur :=0;
temperatur:= 23.64854;
FloatToStr(temperatur, temperatur_text);
result := 0;
end;
//=============================================================
begin
{ Main program }
while true do
begin
x := werte();
//
Delay_ms(1000);
end;
end.
Re: Problem with conversion FloatToString
Hi,
I have tried your code but it was working OK, please see the screenshot below : Which version of the compiler are you using ?
Regards,
Filip.
I have tried your code but it was working OK, please see the screenshot below : Which version of the compiler are you using ?
Regards,
Filip.
Re: Problem with conversion FloatToString
Hi filip,
I am using the latest version (6.2).
I think I found the problem:
Optimization level was set to ZERO under the Option -> 'OUTPUT SETTING'.
If I put something else here but 'Zero', everything works under soft simulator or hardware debuger.
Can you check this ?
Regards,
micha
I am using the latest version (6.2).
I think I found the problem:
Optimization level was set to ZERO under the Option -> 'OUTPUT SETTING'.
If I put something else here but 'Zero', everything works under soft simulator or hardware debuger.
Can you check this ?
Regards,
micha
Re: Problem with conversion FloatToString
Hi,
I apologize for the inconvenience, I have reproduced this issue.
Please find the updated __Lib_Conversions.emcl in the attachment, place it in the \mikroPascal PRO for ARM\Uses\ST M4\ folder instead of the existing one.
This should solve your issue.
Regards,
Filip.
I apologize for the inconvenience, I have reproduced this issue.
Please find the updated __Lib_Conversions.emcl in the attachment, place it in the \mikroPascal PRO for ARM\Uses\ST M4\ folder instead of the existing one.
This should solve your issue.
Regards,
Filip.
- Attachments
-
- __Lib_Conversions.rar
- (18.51 KiB) Downloaded 85 times
Re: Problem with conversion FloatToString
Hi filip,
thanks . I will test it in the next few days.
Another question: is there a description of each optimization level?
Regards
micha
thanks . I will test it in the next few days.
Another question: is there a description of each optimization level?
Regards
micha
Re: Problem with conversion FloatToString
Hi,
Not at the moment, but we are planning to add the description in the help file
Regards,
Filip.
Not at the moment, but we are planning to add the description in the help file
Regards,
Filip.
-
- Posts: 3
- Joined: 12 May 2021 10:41
Re: Problem with conversion FloatToString
Hi all. I have same issue.
I replaced "__Lib_Conversions.emcl" file. The problem is not solved.
I have Mikroe M4 with STM32F415RG controller.
Any solutions ?
I replaced "__Lib_Conversions.emcl" file. The problem is not solved.
I have Mikroe M4 with STM32F415RG controller.
Any solutions ?