Go Down

Topic: Saving arrays in EEPROM using ARDUINOMEGA (Read 6 times) previous topic - next topic

PaulS

The function returns the high byte and the low byte on the two calls. The integer is constructed by shifting the high byte 8 places to the left and adding the low byte, as was shown in reply #11. It is NOT constructed by simply adding the two bytes.

The values that you are getting are 1 and 67. Shifting the 1 8 places is equivalent to multiplying by 256. So, 256 + 67 = ? That's right. 323.

Daniel Formosa

aaaaaaaaaaaaaa tnx!!!!!!

now for tomorrow to continue looking in this....

TNX ALL!!!

AWOL

Quote
serial = EEPROM.read(0) + EEPROM.read(1) + EEPROM.read(2);
  Removing read(2) will not give 323


In case you were wondering:
323 decimal = 0x0143

0x01 + 0x43 + 0xFF (the contents of address 2, because you haven't written anything to it) = 0x143 = 323.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Daniel Formosa

Another question pls...

If for example I need integer 1511.  I thought that it would need 3 bytes but 2 are needed(serialmonitered it).

Reading addreses 0 and address 1 i get these values
address 0 - 231
address 1 - 5

So my question is, (looking at reply11), 5 is the HIGH byte right?
How is it worked out?
Moving 5 - 101B to shift 8 places - 10100000000 - 1280??
Adding 231 = 1511

Is this right?
tnx

GaryP

What is 101B, where did it came from?

But if your high byte is 5, then 5 * 256 =1280. That is correct.
1280 + 231 =1511, so that is true as well.


Kari
The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Go Up