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