This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with floating point number

My Hardware has STM32L162VD as main processor and other modules on it like GPRS module SIM900. I noticed that when the hardware is under test after few hours the floating point numbers in RAM registers change only in '.' character to some other characters like 't' or space ' ' or '*' or '0'. I mean the numbers don't change but only the appearance of point changes. I can see the values in Graphical 128x64 LCD and also in the server computer that receives the data using GPRS TCP connection. The numbers change like following every few hours:
1.5 -> 1t5
12.54 -> 12t54
or
1.5 -> 105
12.54 ->12054
or
1.5 ->1 5
12.54 ->12 54

if I write the changed number into the EEPROM and reset the MCU then read it from EEPROM the number goes back to normal appearance. I don't know what is happening to MCU!

Parents
  • This could happen if you have memory corruption.

    Remember that all code in the standard library is also "normal" code. So if your program causes memory corruption, then the CRTL functions may start to misbehave.

    I haven't checked into Keils support for alternative locales - but if the library supports locales, then it's likely that they store the decimal separator in a variable to allow it to be changed depending on locale. Corruption of this memory byte would then make floating-point formatting produce numbers with a strange decimal separator character.

Reply
  • This could happen if you have memory corruption.

    Remember that all code in the standard library is also "normal" code. So if your program causes memory corruption, then the CRTL functions may start to misbehave.

    I haven't checked into Keils support for alternative locales - but if the library supports locales, then it's likely that they store the decimal separator in a variable to allow it to be changed depending on locale. Corruption of this memory byte would then make floating-point formatting produce numbers with a strange decimal separator character.

Children