EEPROM storage of Single variable

Status
Not open for further replies.

Roger Harrold

New Member
I'm using a Single (floating point) value as a calibration constant.
Does anyone know how to store the 4-byte value in EEPROM and
how to read it back?
 
In C I use a union... I should imagine you could use the pointer function to traverse the 4 bytes..

Vladimir MUST have given this functionality surely!!

I'll have a go at it now..
 
It worked

Using the pointer like so..
Code:
Dim eep As Byte  'eeprom address
Dim data As Byte
Dim floater As Single @ 0x30
Dim addr As Word  'ram address
addr  = 0x30
floater = 123.456
main:
   For eep = 0 To 3
     data = Pointer(addr)
     Write eep, data
     addr =addr + 1
   Next eep
   floater = 0
   addr = 0x30
   For eep = 0 To 3
     Read eep, data
     Pointer(addr) = data
     addr = addr + 1
   Next eep     
     
Goto main  'go again

You have to declare the single in ram specifically so you can set the address..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…