How to read and display Word value from EE?
Archiver
Posts: 46,084
I want to store a decimal value in EEPROM and later show it using
DEBUG. Since the number is "large", I need to use Word.
But when I run this below, I don't get 4321, but 225.
What is going on? I'm using PBasic 2.5.
Does anyone know how to read a Word decimal value from EEPROM and
later show it as decimal using DEBUG?
Much thanks in advance.
'{$STAMP BS2}
'{$PBASIC 2.5}
eep VAR Word 'EE pointer
sum VAR Word 'variable used to store data read from EE
data1 DATA Word 4321 'EE data
eep = data1 'point to EE address
READ eep, sum 'read it into sum
DEBUG "number is ", DEC sum, CR 'I want to display sum as decimal!!!
DEBUG. Since the number is "large", I need to use Word.
But when I run this below, I don't get 4321, but 225.
What is going on? I'm using PBasic 2.5.
Does anyone know how to read a Word decimal value from EEPROM and
later show it as decimal using DEBUG?
Much thanks in advance.
'{$STAMP BS2}
'{$PBASIC 2.5}
eep VAR Word 'EE pointer
sum VAR Word 'variable used to store data read from EE
data1 DATA Word 4321 'EE data
eep = data1 'point to EE address
READ eep, sum 'read it into sum
DEBUG "number is ", DEC sum, CR 'I want to display sum as decimal!!!
Comments
>I want to store a decimal value in EEPROM and later show it using
>DEBUG. Since the number is "large", I need to use Word.
>But when I run this below, I don't get 4321, but 225.
>What is going on? I'm using PBasic 2.5.
>
>Does anyone know how to read a Word decimal value from EEPROM and
>later show it as decimal using DEBUG?
>
>Much thanks in advance.
>
>'{$STAMP BS2}
>'{$PBASIC 2.5}
>
>eep VAR Word 'EE pointer
>sum VAR Word 'variable used to store data read from EE
>
>data1 DATA Word 4321 'EE data
>
>eep = data1 'point to EE address
>READ eep, sum 'read it into sum
>DEBUG "number is ", DEC sum, CR 'I want to display sum as decimal!!!
>
Take a look at the DATA directive in the Stamp PBASIC Manual. Near the end
of that section you will see an example of exactly what you are trying to do.
A WORD-sized variable requires two READ commands to extract the DATA. One READ
extracts the HIGHBYTE and the other extracts the LOWBYTE.
Hope that gets you going again.
Regards,
Bruce Bates
READ eep, WORD sum 'read it into sum
Original Message
From: "basicstampede" <basicstampede@y...>
To: <basicstamps@yahoogroups.com>
Sent: Monday, June 09, 2003 4:42 AM
Subject: [noparse][[/noparse]basicstamps] How to read and display Word value from EE?
> I want to store a decimal value in EEPROM and later show it using
> DEBUG. Since the number is "large", I need to use Word.
> But when I run this below, I don't get 4321, but 225.
> What is going on? I'm using PBasic 2.5.
>
> Does anyone know how to read a Word decimal value from EEPROM and
> later show it as decimal using DEBUG?
>
> Much thanks in advance.
>
> '{$STAMP BS2}
> '{$PBASIC 2.5}
>
> eep VAR Word 'EE pointer
> sum VAR Word 'variable used to store data read from EE
>
> data1 DATA Word 4321 'EE data
>
> eep = data1 'point to EE address
> READ eep, sum 'read it into sum
> DEBUG "number is ", DEC sum, CR 'I want to display sum as decimal!!!
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
--- In basicstamps@yahoogroups.com, "GWR at PacBell" <GWR@P...> wrote:
> You need to include the WORD keyword on the read command:
>
> READ eep, WORD sum 'read it into sum
>
>
>
>
Original Message
> From: "basicstampede" <basicstampede@y...>
> To: <basicstamps@yahoogroups.com>
> Sent: Monday, June 09, 2003 4:42 AM
> Subject: [noparse][[/noparse]basicstamps] How to read and display Word value from EE?
>
>
> > I want to store a decimal value in EEPROM and later show it using
> > DEBUG. Since the number is "large", I need to use Word.
> > But when I run this below, I don't get 4321, but 225.
> > What is going on? I'm using PBasic 2.5.
> >
> > Does anyone know how to read a Word decimal value from EEPROM and
> > later show it as decimal using DEBUG?
> >
> > Much thanks in advance.
> >
> > '{$STAMP BS2}
> > '{$PBASIC 2.5}
> >
> > eep VAR Word 'EE pointer
> > sum VAR Word 'variable used to store data read from EE
> >
> > data1 DATA Word 4321 'EE data
> >
> > eep = data1 'point to EE address
> > READ eep, sum 'read it into sum
> > DEBUG "number is ", DEC sum, CR 'I want to display sum as
decimal!!!
> >
> >
> >
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> > from the same email address that you subscribed. Text in the
Subject and
> Body of the message will be ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
(just as the DATA statement does). And as you modified the DATA statement to
store a Word, you can do the same thing with READ. Like this:
READ eep, Word sum
This actually causes the compiler to generate this code:
READ eep, sum.LOWBYTE
READ eep+1, sum.HIGHBYTE
Obviously, using the Word modifier is easier.
-- Jon Williams
-- Parallax
In a message dated 6/9/2003 6:43:42 AM Central Standard Time,
basicstampede@y... writes:
> I want to store a decimal value in EEPROM and later show it using
> DEBUG. Since the number is "large", I need to use Word.
> But when I run this below, I don't get 4321, but 225.
> What is going on? I'm using PBasic 2.5.
>
> Does anyone know how to read a Word decimal value from EEPROM and
> later show it as decimal using DEBUG?
>
> Much thanks in advance.
>
> '{$STAMP BS2}
> '{$PBASIC 2.5}
>
> eep VAR Word 'EE pointer
> sum VAR Word 'variable used to store data read from EE
>
> data1 DATA Word 4321 'EE data
>
> eep = data1 'point to EE address
> READ eep, sum 'read it into sum
> DEBUG "number is ", DEC sum, CR 'I want to display sum as decimal!!!
[noparse][[/noparse]Non-text portions of this message have been removed]