How do I write and read a word to EEPROM?

Tyro

Member
I have read and re-read the read and write pages in manual 2 but cannot understand how to write and read a wordvariable into EEPROM.

There is no wiord example! The example shown has no bearing on word variables and I don't have a serial LCD.

Would someone please give me an example of the two lines of code, one to write and the second to read a word.
 

Dippy

Moderator
"
WRITE location,data ,data, WORD wordvariable...
- Location is a variable/constant specifying a byte-wise address (0-255).
- Data is a variable/constant which provides the data byte to be written. To use a
word variable the keyword WORD must be used before the wordvariable."​
 

Tyro

Member
Unfortunately your reply does not help, it is a copy of the words from the manual. I do not understand it. Just give me the two examples please.
 

BeanieBots

Moderator
READ location,variable,variable, WORD wordvariable

eg this will get the contents of EEPROM location 24 into b7, location 25 into b8 and locations 26 and 27 into word variable w0.
READ 24,b7,b8, WORD w0

It's just as straight forword for WRITE.
WRITE location,data ,data, WORD wordvariable...

location = the address of the EEPROM location.
data = a byte variable
wordvariable = a word variable (must be preceded by the word WORD)
 

Tyro

Member
Thank you Beanie bots.

write 0, WORD w0 'copies word w0 to EEprom starting at location 0
read 0, WORD w1 'copies contents of EEprom starting at location 0 to w1

This was the information I needed.
 

BeanieBots

Moderator
Yep, that's it.
Or more generally, as stated in the manual.

write location, WORD wordvariable
read location, WORD wordvariable

Don't forget to increment "location" in steps of TWO.
 
Top