PDA

View Full Version : EEPROM query: easy for you, a mystery to me!



Experimenter
- 29th October 2014, 20:05
Hi,

I do not understand how I can *apparently* write to 8-bit EEPROM addresses *above 1k* on an 18F46K22.

Unbelievably to me, the following code works just fine, writing and reading back at address 7500.

My ignorance is clearly deeper than I thought! Can anyone shed light on this mystery?

Thank you!


promtest:
y var word
z var word
y = 7500
write y, 100
read y, z
lcdout 254,1
pause 200
lcdout 254,128, #z
END
return

Acetronics2
- 29th October 2014, 20:39
also just try to read @ ...

332
1356
2380
3404
4428
5452

...

just my two cents ...

Alain

Demon
- 29th October 2014, 20:41
Check the manual for the difference between bytes and words. :)

Robert

HenrikOlsson
- 29th October 2014, 21:03
Hi,
What Alain is trying to make you figure out is this:
The EEPROM adress "bus" is 10 bits for adressing locations between 0 and 1023. Only the two least significant bits of the high byte are actually used, look:

1356: 0000010101001100
2380: 0000100101001100
4428: 0010000101001100
7500: 0001110101001100

See the lower ten bits marked in green? Which adress are you really accessing? Yes, 332.

/Henrik.

Experimenter
- 29th October 2014, 21:57
Thank you everyone for showing me this patience.
I have spent days delving successfully in code memory and my confidence was building: suddenly I was confused, in mystery-land again and not happy to be there!

/Experimenter