Shop OBEX P1 Docs P2 Docs Learn Events
Using PUT & GET — Parallax Forums

Using PUT & GET

Vern RoachVern Roach Posts: 9
edited 2005-11-18 11:22 in BASIC Stamp
Dear Parallax People,

On p.245 of the Stamp Manual in refering to Scratch Pad RAM it says that "...each location is always configured as a byte only."··Can I·do the following? :

····················Value·· VAR·· Byte
··················· PUT 0, Value.LOWBYTE
··················· PUT 1, Value.HIGHBYTE

The Stamp Editor didn't balk when I entered the above lines, but I wanted to be sure.

Vern Roach

·········

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-15 02:10
    The code you've posted doesn't actually work -- is there a typo and is "value" actually a Word?· PUT and GET are used to put and get bytes to/from the Scratchpad RAM.· With PBASIC 2.5 you can do this:

    · PUT 0, Word value

    What the compiler does is generate this code for you:

    · PUT 0, value.LOWBYTE
    · PUT 1, value.HIGHBYTE

    You can also PUT/GET multiple values like this:

    · PUT 0, status, Word value

    For this the compiler would generate:

    · PUT 0, status
    · PUT 1, value.LOWBYTE
    · PUT 2, value.HIGHBYTE

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 11/15/2005 2:13:33 AM GMT
  • Vern RoachVern Roach Posts: 9
    edited 2005-11-15 02:53
    Jon,

    Thanks for being perceptive - Yes, I did mean "Value VAR Word". And thank you for elaborating on the capabilities of PBASIC 2.5. The ability to use GET & PUT very much like READ & WRITE really takes the restrictions off what might seem like a not-too-large RAM capacity. (To 3rd parties: I'm truly a beginner at this!)

    Thanks again
    Vern Roach
  • superoosuperoo Posts: 5
    edited 2005-11-15 06:38
    Just in case you eventually end up short of code space...

    Put 0, value.lowbyte
    Put 1, value.highbyte

    actually uses less code space than...

    Put 0, word value




    ·
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-11-15 14:32
    Note the EEPROM only supports about a million writes. During normal 'programming' use, this should last a decade or more. If you write to the same location once every millisecond though, you can wear it out in a week.

    This is not a problem exactly, just something to be aware of.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2005-11-15 14:56
    That's something I hadn't thought about -- ScratchpadRAM is actually EEPROM space, then?

    -- PJA --
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-15 15:24
    No, the Scratchpad is RAM. That said, PUT and GET (RAM) are analogous to WRITE and READ (EEPROM).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-15 15:25
    PUT and GET have no effect on EEPROM.
    allanlane5 said...
    Note the EEPROM only supports about a million writes. During normal 'programming' use, this should last a decade or more. If you write to the same location once every millisecond though, you can wear it out in a week.

    This is not a problem exactly, just something to be aware of.
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-11-15 15:25
    No,

    ·· The ScratchPad RAM is just that, RAM, and has an unlimited number of write cycles, just as variable space does.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2005-11-15 16:25
    Thanks, guys -- I can breathe again.
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-11-15 18:20
    D'oh! Sorry about that folks. "Get" and "Put" are for ScratchPad RAM, which has NO write or read limitations, on the BS2p variants. "Write" and "Read" are for EEPROM, which is on all BS2 variants, and can only be written 1 million times.

    I've learned my lesson now. Sorry about any confusion.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-11-15 18:47
    allanlane5 said...
    D'oh! Sorry about that folks. "Get" and "Put" are for ScratchPad RAM, which has NO write or read limitations, on the BS2p variants. "Write" and "Read" are for EEPROM, which is on all BS2 variants, and can only be written 1 million times.
    I've learned my lesson now. Sorry about any confusion.
    Okay Homer,

    ·· While we're getting technical, the EEPROM write life of the BS1 & BS2 is 10,000,000 (Ten Million) writes.· The BS 2e, BS 2sx, BS 2p, and BS 2pe EEPROM is guaranteed for 100,000 write cycles before it wears out.· =)

    Oooh, a donut!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • HIBITDACHIBITDAC Posts: 40
    edited 2005-11-18 09:40
    I'm trying to write 42 to the scratch pad and when I get it back out it's 420 not 42. It does this for every number execpt for 0.
    If I put 4 in, I get 4 out. Seems like double digit numbers dont want·to work right.

    Temp1 = 42
    PUT 1, Temp1
    .
    .
    .
    GET 1, Temp1
    DEBUG "Temp1=", DEC Temp1

    I've tried...

    PUT 1,Temp1.LOWBYTE
    PUT 1,Temp1.HIGHBYTE

    Nothing seems to work.

    Edit: Oh yeah I'm using a BS2P40

    Post Edited (HIBITDAC) : 11/18/2005 10:31:23 AM GMT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-11-18 10:02
    HIBITDAC -

    You failed to mention how Temp1 is defined, WORD, BYTE, NIB? It's always best to include the whole program when asking for assistance on a question like this.

    Regards,

    Bruce Bates
  • HIBITDACHIBITDAC Posts: 40
    edited 2005-11-18 10:38
    I would post my program but its spans 5 slots, and jumps all over the place so you would probably get lost.

    I've defined as Word...samething, Byte...samething, Nib...samething.

    If I...

    Temp1 = 38

    Put 1 Temp1

    Get 1,Temp1

    Temp1 = Temp1 / 10

    It displays 30, samething with 52 execpt it displays 50. seems like it is adding a zero for no reason.

    Post Edited (HIBITDAC) : 11/18/2005 10:41:32 AM GMT
  • HIBITDACHIBITDAC Posts: 40
    edited 2005-11-18 11:22
    NEVERMIND..SUPER STUPID moment.
Sign In or Register to comment.