C
cerr
Hi There,
I have an array of 16 16bit values that i need to store in an 8bit
eeprom.
It seems to be fine but I read back all weird values.
I tried to do it this way:
void WriteToEEPROM(eevalues* data)
{
int8 i=0;
for (i=0; i<VARNUM; i++){
write_eeprom((i*2),*((int8*)&(data->value)));
write_eeprom((i*2)+1,*((int8*)&(data->value) + 1));
}
}
//------------------------------------------------------------------------------
void ReadFromEEPROM(eevalues* data)
{
int8 i;
for (i = 0; i<VARNUM; i++){
data->value=0x0000;
*((int8*)&(data->value)) = read_eeprom((i*2));
*((int8*)&(data->value)+1) = read_eeprom((i*2)+1);
}
}
May anyone point me into the right direction? We can assume that
write_eeprom() and read_eeprom() work just fine and expect the address
to write to/read from (starting at 0) and the value resp. it returns
the value as a int8.
Thanks for hints or suggestions!
Ron
I have an array of 16 16bit values that i need to store in an 8bit
eeprom.
It seems to be fine but I read back all weird values.
I tried to do it this way:
void WriteToEEPROM(eevalues* data)
{
int8 i=0;
for (i=0; i<VARNUM; i++){
write_eeprom((i*2),*((int8*)&(data->value)));
write_eeprom((i*2)+1,*((int8*)&(data->value) + 1));
}
}
//------------------------------------------------------------------------------
void ReadFromEEPROM(eevalues* data)
{
int8 i;
for (i = 0; i<VARNUM; i++){
data->value=0x0000;
*((int8*)&(data->value)) = read_eeprom((i*2));
*((int8*)&(data->value)+1) = read_eeprom((i*2)+1);
}
}
May anyone point me into the right direction? We can assume that
write_eeprom() and read_eeprom() work just fine and expect the address
to write to/read from (starting at 0) and the value resp. it returns
the value as a int8.
Thanks for hints or suggestions!
Ron