read and write from/to EEPROM

Hi everyone,

I get an unexpected result when I read from EEPROM.

Can someone please help me to solve what is wrong !

My code:

int counter = 0; // write calibration data to EEPROM
for(int i = 0; i < 3; i++){
EEPROM.write(counter++, highByte((int)round(Offset*))); *
_ EEPROM.write(counter++, lowByte((int)round(Offset*)));_
_
}_
_
for(int i = 0; i < 3; i++){ _
_ EEPROM.write(counter++, highByte((int)round(Sens)));
EEPROM.write(counter++, lowByte((int)round(Sens)));
}*_

* //read calibration data from EEPROM*
* int counter = 0;*
* for(int i = 0; i < 3; i++){ *
_ Offset = word(EEPROM.read(counter++), EEPROM.read(counter++));
* }
for(int i = 0; i < 3; i++){
Sens = word(EEPROM.read(counter++), EEPROM.read(counter++));
} *

output:
EEPROM Offsets for X, Y, Z:
46.00, 16.00, 65426.00
EEPROM Sensitivities for X, Y, Z:
648.00, 658.00, 652.00
OffsetX had the value of -109. The other data are correct._

Funny thing is that 65535 - 109 = 65426.
Thanks for your suggestions, Newbee

EEPROM.write(counter++, highByte((int)round(Offset[i])));

What is the round() function expecting as input? What is it returning as output? I'd be inclined to break this up into multiple steps, and print values out until I understood where the issue was occurring.

It looks as though some part of the process of writing data to, or reading data from, the EEPROM is expecting the data to be unsigned. When it isn't the data is not stored correctly. With everything happening in one statement, it's hard to debug.