Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp 2pe program slots — Parallax Forums

Basic Stamp 2pe program slots

blacksheep45blacksheep45 Posts: 41
edited 2008-12-15 19:54 in BASIC Stamp
How many program slots does the BS2pe allow? Because on the stamp comparison sheet it says that the BS2pe allows 16x2K Bytes.
But when i try to add more than 8 programs it says that it cannot add more than 7 additional project files.

Can anyone help?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-15 16:16
    The documentation states that only the first 8 slots (0-7) can be used for programs. The other 8 slots (8-15) are for storing data only. The Stamp Editor supports only 8 project files for the first 8 slots.

    There are some ways around this, but they're not simple and there's no way around the limitation as far as the Stamp Editor is concerned.
  • blacksheep45blacksheep45 Posts: 41
    edited 2008-12-15 16:53
    What are the possible ways around this?



    Regards

    Shaun
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-15 17:05
    There were some postings recently from Tracy Allen who indicated that the interpretive code for the RUN statement actually allows more than 8 slots. You could write the slot programs for slots 8-15 and load them into slots 1-7 one or more at a time, then write a program to copy them to their actual slots using the STORE / READ / WRITE statements.

    This is awkward at best and would make debugging difficult. It would be a very unusual situation where this would be necessary, particularly since most programs that don't fit into one or a few slots have a lot of waste in them and can be trimmed down quite a bit. Often switching to a table-driven structure for your program will markedly reduce its complexity and size (moving the complexity into the table(s)).
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2008-12-15 17:47
    Hi Mike,

    I didn't say that those slots could be used to run programs. As you correctly pointed out, slots 8 to 15 can only hold DATA, and it is not possible to execute code in those banks. However, at times it is convenient to create slots in the editor that contain predefined DATA to load into slots 8 to 15, but the IDE does not allow that either. The only access provided to those slots is at run time, via the STORE, READ and WRITE commands. The workaround I came up (using the Stache as an intermediary) invokes a "loophole" the native BS2pe programming algorithm to redirect DATA to the higher slots.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-15 17:50
    Sorry, I misunderstood
  • ZootZoot Posts: 2,227
    edited 2008-12-15 18:38
    Wouldn't it be possible, however, to use, say, one slot as a "utility" that copies all the bytecodes from a slot at 8-15 to a slot in 0-7, then run it? It would be slow (for the copy) but in theory you could have the main utility put the "core" of the Stamp into different program "modes".

    E.g. --- pseudo code

    
    '--- slot 0 code ---
    Main:
    
    ' ... lots of code
    
    loadProg = $A3  ' a global byte variable; if <> 0 then copy slot HIGHNIB to slot LOWNIB
    ' so above would copy slot 10 to slot 3
    
    
    RUN 7 ' utility slot -- this can be last statement in any slot 0-6 if more than one slot is used for main "program"
    
    '--- slot 7 code ---
    
    IF loadProg <> 0 AND loadProg.HIGHNIB >= 8 AND loadProg.LOWNIB <= 6 THEN ' error check
       FOR EEaddr = 0 TO $7FF
          STORE loadProg.HIGHNIB
          READ EEaddr, ioByte
          STORE loadProg.LOWNIB
          WRITE EEaddr, ioByte
       NEXT
       loadProg = $00 ' reset so mainline doesn't have to
    ENDIF
    
    RUN 0
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php


    Post Edited (Zoot) : 12/15/2008 6:47:25 PM GMT
  • ZootZoot Posts: 2,227
    edited 2008-12-15 18:43
    P.S. -- actually this same kind of schema could load "pages" of bytecode from an external EEPROM as well. Even if took some real time to copy over several slots of a "new" program, it could be interesting to explore for some projects (I'm thinking a mod to a robotic platform -- say you write one or two slots of data that need to be parsed and rewritten extensively --- say mapping solutions -- have the 'bot park, copy over the navigation program to the main slots, run 'em on the data, write the "solution", copy the main subsumption/sensor 'bot package *back* over, get into motion...)


    Somebody *has* to have done something like this already smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-12-15 19:00
    The biggest problem I see with the "copy-and-paste" scheme is the write endurance of the main EEPROM. Under the wrong circumstances, it could get hammered pretty badly.

    -Phil
  • ZootZoot Posts: 2,227
    edited 2008-12-15 19:16
    PhiPi -- yeah, I was just thinking about that -- I'm thinking about mode switches that might be at most several times per day or so, not every few minutes or even every hour. Also, I would probably do this on an OEM Stamp and socket the Stamp EEPROM.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • ZootZoot Posts: 2,227
    edited 2008-12-15 19:23
    Shaun -- FYI what Tracy was talking about is something like this:

    
    ' --- slot 0 --- program
    EEaddr VAR Word
    ioByte  VAR Byte
    
    DEBUG CLS, "Copying data from slot 1 to slot 15..."
    
    FOR EEaddr = $000 TO $7FF
       STORE 1
       READ EEaddr, ioByte
       STORE 15
       WRITE EEaddr, ioByte
       DEBUG CR, "addr: ", IHEX4 EEaddr, "   data: ", IHEX2 ioByte
    NEXT
    
    
    DEBUG CR, "Done..."
    
    DO : LOOP
    END
    
    



    ' slot 1 -- all data ---- 
    DATA 1
    DATA 2
    DATA 3
    ' etc
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2008-12-15 19:54
    The scheme that uses STORE/READ/WRITE does work well for occasional updates slot to slot, or external memory to slot, or comms port to slot. It is a good way to bring in something like a new "driver" or a list or script data. It does require a PBASIC program to execute the scheme and perhaps attention to data integrity (checksum), and it can't be done so often as to wear out the eeprom.

    The alternative I was referring to does not involve a PBASIC program running on the Stamp and can work on a totally uninitialized Stamp. It simply relies on the same algorithm that the IDE uses to program the Stamp. The loophole is that the BS2pe internal programming algorithm recognizes all slot addresses from 0 to 15 and can happily load in data directed any of those. I mentioned that I use a special version of the Stache for this, but it can also be DIY Stamp to Stamp using www.emesys.com/BS2clone.htm. Just go in and edit the target slot address. Say you have data in slot 1 on the master Stamp and you want it to go to slot 12 on the clone. Then just change the one byte in the image that selects the slot you want.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.