How to write and read word-sized(16-bit)data to EEPROM?
I can´t figure out how to write and read word-sized data to the
EEPROM. Byte-sized are no problem. I have tested something like this:
myword var word
EEaddr var word
myword =260
WRITE EEaddr, myword
read EEaddr , myword
debug "Reading myword= ", dec myword,tab,cr
Since 260 does not fit into a byte the debug shows the result of 6
(260-256).
Is there an easy way to store word instead of byte in the EEPROM?
EEPROM. Byte-sized are no problem. I have tested something like this:
myword var word
EEaddr var word
myword =260
WRITE EEaddr, myword
read EEaddr , myword
debug "Reading myword= ", dec myword,tab,cr
Since 260 does not fit into a byte the debug shows the result of 6
(260-256).
Is there an easy way to store word instead of byte in the EEPROM?
Comments
myword var word
EEaddr var word
EEaddr = 0
myword =260
WRITE EEaddr, myword.lowbyte
EEaddr = EEaddr + 1
WRITE EEaddr, myword.highbyte
read EEaddr , myword.lowbyte
EEaddr = EEaddr + 1
read EEaddr, myword.highbyte
debug "Reading myword= ", dec myword,tab,cr
regards, Chris Anderson
Original Message
From: <torsten.stahlberg@s...>
To: <basicstamps@egroups.com>
Sent: Tuesday, August 08, 2000 5:47 PM
Subject: [noparse][[/noparse]basicstamps] How to write and read word-sized(16-bit)data to
EEPROM?
> I can´t figure out how to write and read word-sized data to the
> EEPROM. Byte-sized are no problem. I have tested something like this:
>
> myword var word
> EEaddr var word
> myword =260
> WRITE EEaddr, myword
> read EEaddr , myword
> debug "Reading myword= ", dec myword,tab,cr
>
> Since 260 does not fit into a byte the debug shows the result of 6
> (260-256).
> Is there an easy way to store word instead of byte in the EEPROM?
>
>
>
>
>
torsten.stahlberg@s... writes:
> I can´t figure out how to write and read word-sized data to the
> EEPROM. Byte-sized are no problem. I have tested something like this:
>
> myword var word
> EEaddr var word
> myword =260
> WRITE EEaddr, myword
> read EEaddr , myword
> debug "Reading myword= ", dec myword,tab,cr
>
> Since 260 does not fit into a byte the debug shows the result of 6
> (260-256).
> Is there an easy way to store word instead of byte in the EEPROM?
You need two WRITEs and two READs to handle word-sized variables. Like this:
WRITE EEaddr, myword.LOWBYTE
WRITE EEaddr+1, myword.HIGHBYTE
then...
READ EEaddr, myword.LOWBYTE
READ EEaddr+1, myword.HIGHBYTE
-- Jon Williams
-- Dallas, TX
and read it back as two reads, one for high one for low.
Norm & Monda
Cozy MK IV #202
Ford V-6 Powered
Original Message
From: <torsten.stahlberg@s...>
To: <basicstamps@egroups.com>
Sent: Tuesday, August 08, 2000 5:47 AM
Subject: [noparse][[/noparse]basicstamps] How to write and read word-sized(16-bit)data to
EEPROM?
I can´t figure out how to write and read word-sized data to the
EEPROM. Byte-sized are no problem. I have tested something like this:
myword var word
EEaddr var word
myword =260
WRITE EEaddr, myword
read EEaddr , myword
debug "Reading myword= ", dec myword,tab,cr
Since 260 does not fit into a byte the debug shows the result of 6
(260-256).
Is there an easy way to store word instead of byte in the EEPROM?