large value in external EE
Archiver
Posts: 46,084
In a message dated 7/6/2004 1:33:22 PM Eastern Daylight Time,
basicstampede@y... writes:
> Does anyone have a suggestion on how to store a large number in
> external EE and then retrieve it to a BS2 word variable?
Divide your number by 256, like in:
n = 50000
z = 50000/256
store n as a byte. n will be stored as 80, which is the lower byte of 50000.
store z as a byte - 50000/256 = 195.
When you read them back out, reconstitute by writing
n = n + (z*256)
80 + 49920 = 50000
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
basicstampede@y... writes:
> Does anyone have a suggestion on how to store a large number in
> external EE and then retrieve it to a BS2 word variable?
Divide your number by 256, like in:
n = 50000
z = 50000/256
store n as a byte. n will be stored as 80, which is the lower byte of 50000.
store z as a byte - 50000/256 = 195.
When you read them back out, reconstitute by writing
n = n + (z*256)
80 + 49920 = 50000
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
EEPROM such as 24C02C.
My first thought is to use 2 EE bytes. e.g. use location 0 and 1
with 0 holding the lower 8 bits and 1 holding upper 8 bits of my 16
bit data.
But when I retrieve the data, it does not seem correct.
Does anyone have a suggestion on how to store a large number in
external EE and then retrieve it to a BS2 word variable?
Thanks.
Write the LOWBYTE of your value to Address, the HIGHBYTE of your value
to Address + 1. Reading is just a reverse of the process: read the
LOWBYTE of your value from Address, the HIGHBYTE from Address + 1. The
LOWBYTE and HIGHBYTE variable modifiers make the process fairly simple.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: basicstampede [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Gd6UoTM5RwwB2y8veluRdHEay9H6omLxyUWaVRJIxL15IeuiCu-egpbhTIKNp8Bq9pxWndiF47DraTRy7p0]basicstampede@y...[/url
Sent: Tuesday, July 06, 2004 12:27 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] large value in external EE
I want to store a large integer number (up to 50,000) in an external
EEPROM such as 24C02C.
My first thought is to use 2 EE bytes. e.g. use location 0 and 1
with 0 holding the lower 8 bits and 1 holding upper 8 bits of my 16
bit data.
But when I retrieve the data, it does not seem correct.
Does anyone have a suggestion on how to store a large number in
external EE and then retrieve it to a BS2 word variable?
Thanks.
I do predefine the starting value with an EEPROM statement,
probably not needed but the defaults work for over 50% of the units so less
than half need changing.
Watch your formatters, you may be storing the ASCII code of the digits or
something like that.
KF4HAZ - Lonnie
From: "basicstampede" <basicstampede@y
> I want to store a large integer number (up to 50,000) in an external
> EEPROM such as 24C02C.
>
> My first thought is to use 2 EE bytes. e.g. use location 0 and 1
> with 0 holding the lower 8 bits and 1 holding upper 8 bits of my 16
> bit data.
>
> But when I retrieve the data, it does not seem correct.
>
> Does anyone have a suggestion on how to store a large number in
> external EE and then retrieve it to a BS2 word variable?
>
> Thanks.