how to convert integer to byte and viceversa (by simon)
Hi
I need to convert integer to byte to save on eeprom and convert byte to integer to read from eeprom .
I need help
Thank you
(no subject) (by Jonathan Westhues)
I'm not sure what you're trying to do. LDmicro supports a "make persistent" operation, which will cause a variable to be saved to EEPROM whenever it changes; but that operation already works on integer variables, so there's no need to do any conversion.
(no subject) (by simon)
Hi Jonathan
Thank you for response. I have a project that uses a diferent compiler , not using LDmicro ,and is imposible to save values bigger than 255 . I have no ideea how to save value bigger than 255 . I am using floating point and integer, and integer is bigger than 1023 .
Thank you
(no subject) (by esa)
I use a EEPROM to save word in EEPROM
You must transfert in two byte to read and write the value.
For Float, you must use 4 byte.
Above, my sub routine
Regards
ERic
int16 transfer (int16 data, int8 RW)
{
int8 datah,datal;
datah=data/256;
datal=data-256*datah;
if (RW==LOAD_EEPROM)
{
datal=read_ext_eeprom(cellule);
cellule++;
datah=read_ext_eeprom(cellule);
cellule++;
}
else
{
write_ext_eeprom(cellule,datal);
cellule++;
write_ext_eeprom(cellule,datah);
cellule++;
}
data=datah*256+datal;
return(data);
}