View previous topic :: View next topic |
Author |
Message |
Guest
|
How to write 16bit using WRITE_EXT_EEPROM( address, value ); |
Posted: Wed Oct 06, 2004 10:55 am |
|
|
hi there.
i'm currently looking on WRITE_EXT_EEPROM( address, value );
what i want to do is store 16bit value into my eeprom.how can i do that?. |
|
|
mvaraujo
Joined: 20 Feb 2004 Posts: 59 Location: Brazil
|
|
Posted: Wed Oct 06, 2004 11:28 am |
|
|
You can save two bytes in sequence! One in each address! |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Oct 06, 2004 2:03 pm |
|
|
Saving each byte in sequences all you get is two consecutive bytes stored in external EEPROM,
to affect the whole number to be able to operate arithmetically you need to create a struct.
Code: |
#define addr_varH 0x1000
#define addr_varL addr_varH + 1
struct BigVar{
int8 varL;
int8 varH;
};
union store{
long WordValue;
struct BigVar double_var;
}Stuff;
// to access a byte:
varH = read_ext_eeprom(addr_varH);
varL = read_ext_eeprom(addr_varL);
// to write a byte:
write_ext_eeprom(addr_varH, Stuff.double_var.H);
write_ext_eeprom(addr_varL, Stuff.double_var.L);
// to modify the whole number:
WordValue += 1;
|
Best wishes,
Humberto |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
|
|