Velocity Reviews > 16bit values into 8bit eeprom

16bit values into 8bit eeprom

cerr
Guest
Posts: n/a

 02-17-2011
Hi There,

I'm having troubles storing an array of 16 16bit values into an 8bit
eeprom and read it back.
I read all weird values... . My functions look like this:
void WriteToEEPROM(eevalues* data)
{
int8 i=0;
for (i=0; i<VARNUM; i++){
write_eeprom((i*2),*((int8*)&(data[i]->value)));
write_eeprom((i*2)+1,*((int8*)&(data[i]->value) + 1));
}
}
//------------------------------------------------------------------------------

{
int8 i;

for (i = 0; i<VARNUM; i++)
}

May anyone be able to help me and point me into the right direction?
Thank you!

Ike Naar
Guest
Posts: n/a

 02-17-2011
On 2011-02-17, cerr <(E-Mail Removed)> wrote:
> I'm having troubles storing an array of 16 16bit values into an 8bit
> eeprom and read it back.
> I read all weird values... . My functions look like this:
> void WriteToEEPROM(eevalues* data)
> {
> int8 i=0;
> for (i=0; i<VARNUM; i++){
> write_eeprom((i*2),*((int8*)&(data[i]->value)));
> write_eeprom((i*2)+1,*((int8*)&(data[i]->value) + 1));
> }
> }
>
> void ReadFromEEPROM(eevalues* data)
> {
> int8 i;
>
> for (i = 0; i<VARNUM; i++)
> *((int8*)&(data[i]->value)) = read_eeprom((i*2));
> *((int8*)&(data[i]->value)+1) = read_eeprom((i*2)+1);
> }

You're missing a pair of curly braces around the body of the
for loop in ReadFromEEPROM.