Eeprom and Floating point
grasshopper
Posts: 438
I am trying to put some numbers in EEprom that are in floating point. I was converting them to an integer by multiplying them by 100 and truncating them. My problem is that it works for one number but when I put in more numbers it wont work.
Here is a clip of my code. I am using the BS2 object.
Software_Version should be 2.34
and mode could be 100.23
Is this the correct approach?
Here is a clip of my code. I am using the BS2 object.
Pub WriteEEprom | Temp, Temp2 Temp := Ft.Fmul(Software_Version,(Ft.Ffloat(100))) Temp2 := ft.FTrunc(Temp) Memory.Write_HighMem(10,Temp2,4) ser.str(@F1_CV) ser.dec(Temp2) ser.str(@CB) Temp := Ft.Fmul(Mode_Value,(Ft.Ffloat(100))) Temp2 := ft.FTrunc(Temp) Memory.Write_HighMem(20,Temp2,4) ser.str(@F1_CV) ser.dec(Temp2) ser.str(@CB)
Software_Version should be 2.34
and mode could be 100.23
Is this the correct approach?
Comments
Memory.Write_HighMem(10,Software_Version,4)
Memory.Write_HighMem(20,Mode_Value,4)
Post Edited (Mike Green) : 11/17/2008 5:12:53 PM GMT
This worked below
This below would not work
Thanks
I did look at the BS2 routines. The first parameter is an EEPROM byte address from 0 to 32767 that applies to the 2nd 32K of EEPROM.