Shop OBEX P1 Docs P2 Docs Learn Events
large value in external EE — Parallax Forums

large value in external EE

ArchiverArchiver Posts: 46,084
edited 2004-07-06 18:48 in General Discussion
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]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-07-06 18:26
    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.
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-06 18:33
    You have the right idea, the problem must be in your implementation.
    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.
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-06 18:48
    I have had no trouble using READ and WRITE commands with the stamp.
    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.
Sign In or Register to comment.