Shop OBEX P1 Docs P2 Docs Learn Events
Data Statement — Parallax Forums

Data Statement

TomSTomS Posts: 128
edited 2005-12-02 05:22 in BASIC Stamp
I want to store a large table in a program slot other than 0 and will access it using the STORE and READ statements. There doesn't seem to be a way to direct the DATA statement to anything other than program slot 0. Is there another way? I'm thinking I may have to write a small program that transfers data stored in program slot 0 to the other program slots. Which raises the question; does a program transfer after compile from computer to basic stamp only write to program slot 0?

Tom

Comments

  • NewzedNewzed Posts: 2,503
    edited 2005-11-27 14:16
    You can write a DATA statements in any of the banks; however, the DATA will only be available to the bank containing the DATA.· If you want to write data accessible by all banks then you must use the STORE command.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • TomSTomS Posts: 128
    edited 2005-11-27 14:56
    OK. How do I use the DATA statement with bank 1, for example. If after writing data to bank 1 with the DATA statement, why can't I READ data from bank 1 after using STORE 1?

    Thanks
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-27 15:08
    What you have to do is create a separate program file with your data from slot 1 -- it can contain nothing but DATA statements. In your $STAMP directive you tell the editor to load the other slot file:

    · ' {$STAMP BS2p, MyData.BSP}

    In your main program you would use STORE 1 to point to slot 1 for use with READ and WRITE.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • NewzedNewzed Posts: 2,503
    edited 2005-11-27 15:11
    You can not use the STORE command to read a DATA statement.· You can only Read data with the STORE command if the STORE command has been used to WRITE data.· In bank 1, you can READ the data statement just by writing:

    READ addr,· variable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-27 15:16
    STORE sets the slot that is used by both READ and WRITE.· Take a look at our DS2760 thermocouple program as an example -- all of the thermocouple tables are stored in separate slots and READ is used from slot 0 to access them.· Reading from a slot different from where the program is currently running does not require WRITE before READ.

    From the Help file:

    · Syntax: STORE ProgramSlot

    · Function
    · Designate a program slot for the READ and WRITE instructions to operate upon.


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

    Post Edited (Jon Williams (Parallax)) : 11/27/2005 3:19:48 PM GMT
  • NewzedNewzed Posts: 2,503
    edited 2005-11-27 15:36
    Jon, I read your post before you edited it.·

    What I ws trying to say was that I don't think you can read a DATA statement with the STORE command unless the DATA statement had been written by a STORE command.· I could be wrong.

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-27 15:48
    To be clear, STORE is probably not the best name for that instruction because it implies the use of WRITE, but that is not required.· The purpose of STORE is to select the slot to be used for both READ and WRITE.· Again, I encourage you to have a look at the DS2760 program that uses STORE to point to the slot that holds the thermocouple table for the selected thermocouple type.· WRITE is not used anywhere in that program.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • NewzedNewzed Posts: 2,503
    edited 2005-11-27 15:55
    Understood.· That will work for the BS2P and banks 0-7 of the BS2pe.· If you want to use banks 8-15 on the BS2pe, you have to use the STORE command to WRTE and to READ.· That is where I got derailed.

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-27 16:43
    This part is true; you cannot put program files into slots 8 - 15 of the BS2pe -- those slots are devoted to datalogging.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • TomSTomS Posts: 128
    edited 2005-11-27 17:27
    Jon, Sid,

    Thanks for the answers. Now one more related question.
    Let's say I've include the proper compiler directive and successfully stored the data in slot(s) 1- 7. If I now comment out the directive and re-compile the program, will it overwrite the slot with my table or will it remain intact?

    Tom
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-27 17:29
    You can tell the editor to download just the active slot and it will leave the others alone. Go to the Properties dialog, select Editor Operation, then set Download Mode to "Current" or "Modified"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • TomSTomS Posts: 128
    edited 2005-11-27 17:33
    That means I don't have to comment it out.

    Great. Thanks Again
    Tom
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-11-27 17:51
    Tom,
    You didn't say which Stamp you have. The STORE command is only available on the BS2p, BS2pe and BS2px. If you have a BS2e or BS2sx, there are 8 banks available, but not the STORE command.

    Think of the STORE command as a noun, not a verb. It is selecting which STORE (0 to 7) to patronize.

    The compiler will leave untouched any program slot that is not referenced. So you if you take a reference to a slot out of the directive, whatever was there in the Stamp will stay there. Also, within a slot, you can tell the compiier to leave certain blocks of bytes alone. You might want to do that in order to store serial numbers or settings or accumulations.

    DATA (16) ' skips over the block of eeprom from addresses 0 to 15 -- the compiler leaves them as they are in the Stamp
    xtable DATA @128,(16) ' skips over the block or eeprom addresses from 128 to 143, referenced with label "xtable"

    These have to be done in blocks of 16 bytes, on 16 byte boundaries within the eeprom.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • dbjdbj Posts: 75
    edited 2005-12-02 05:22
    If you want to point to a specific table·without·useing the DEBUGIN··, say KTablePos.BPE in the Demo,·would you use the·STORE to point to that specific table?·· STORE (type 0)
    Thanks
Sign In or Register to comment.