Shop OBEX P1 Docs P2 Docs Learn Events
BS2pe : cannot use all the program slots — Parallax Forums

BS2pe : cannot use all the program slots

BettingerJBettingerJ Posts: 7
edited 2008-12-16 01:03 in BASIC Stamp
Hi, I am using a BS2pe stamp and am trying to write a software program which uses all 16 program slots of 2k eeprom memory space each. The following code allows me to link the different programs slots to make a single program (for want of a better expression):

' {$STAMP BS2PE,STORE1.BPE,STORE2.BPE,STORE3.BPE,STORE4.BPE,STORE5.BPE,STORE6.BPE,STORE7.BPE}

However, this appears to be the maximum allowed, if I try to continue and link program slots 8 to 15 then I get the error message "Can not specify more than 7 additional project files." As this amount is not enough for my application, can anybody tell me how I can include all the program slots into a single program?

thanks in advance
John.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-12-05 22:18
    I thought there were only 8 slots total.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-12-05 22:31
    From the Stamp manual:
    James Madison, author of the Stamp Manual said...
    Syntax: STORE ProgramSlot

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

    ProgramSlot is a variable/constant/expression (BS2p and BS2px: 0 – 7, BS2pe: 0 - 15) that specifies the program slot† to use for READ and WRITE instructions.

    † Note: On the BS2pe, slots 8 - 15 are only available for data (READ and WRITE); they cannot be used to run programs.
  • BettingerJBettingerJ Posts: 7
    edited 2008-12-07 21:20
    Hi again,
    I have read what the Stamp manual sayes but am still at a loss. I want to have my program run in slots 0,1,2 and my data stored in 3 thru 15. I want to find a way to fill the slots 3 - 15 with my data. I did write a "Data Loading" program which writes the data into each slot one at a time but this doesn't work as the data needs a DATA directive in front of it in order to be read, which to my knowledge can only be achieved in a program slot. Can somebody tell me the right way to fill my program slots 3-15 with data,

    thanks
    John.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-12-07 21:34
    The data in slots 8-15 has to be put there with STORE and WRITE commands by a program running from any of slots 0-7. You cannot upload these slots directly from the PC. You don't need to initialize slots 8-15 with anything (i.e. a DATA statment) to WRITE or READ data there. The DATA statement is just a way to declare data in a program, but you're not putting programs in those slots.

    If your data is already in DATA statements, you can load each block into slot 7, say, with a program to READ the data from slot 7 and reWRITE it to a slot in the 8-15 range. This will take several iterations to accomplish, but once it's there, it will stay there until rewritten.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 12/7/2008 9:41:30 PM GMT
  • BettingerJBettingerJ Posts: 7
    edited 2008-12-07 22:12
    Phil,
    your solution is the same as what I did earlier, I used a program in slot 0 to read a data byte in the same slot and write it to slots 3-15, I would complete one slot at a time, reading and writing one byte at a time until moving on to the next slot. My lcd display showed me the progression thru the programslots and later I would load in my main program which uses the data in slots 3-15, however it was not able to read the data. Obviously I'm doing something wrong, just trying hard to fiqure out what it is, thks for your help.

    John.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-07 22:23
    How are you using the STORE statement in your programs to select which slot is affected by the READ and WRITE statements? Be sure to read the chapters in the Basic Stamp Manual for the DATA / READ / STORE / WRITE statements if you haven't already.
  • BettingerJBettingerJ Posts: 7
    edited 2008-12-08 00:20
    Mike,
    the program I use to load in all my data has the following to write data to other program slots, the variable PGMSLOT is incremented until slots 3-15 are all written to, this is just a part of my code, of course. The data lines are part of slot 0 program, they are 19bytes in length for each DATA directive:

    START2:
    FOR B = 0 TO 18
    STORE 0
    READ X, A
    STORE PGMSLOT
    WRITE X, A
    X = X + 1
    NEXT
    IF X = 1634 THEN GOTO START3
    GOTO START2
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-08 00:33
    What you've shown here should work as long as X is initialized properly somewhere.
  • BettingerJBettingerJ Posts: 7
    edited 2008-12-08 00:45
    Mike,
    I do set X to zero as I move on to the next pgmslot. After this data loading program is complete I run my main program, the one which uses slots 0-2 for program and 3-15 for data. Strange thing is that the program is able to read data from slots 3-5 perfectly but nothing from 6-15. It had occured to me that this may be a hardware problem but hopefully not.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-08 01:18
    It doesn't make any sense that it would be a hardware problem. There's nothing particularly different about slots 6 through 15. It's all contiguous EEPROM space. I would carefully check your code that distinguishes among different slots or selects the slot to either copy data to or read it from the slot.
  • awesomeduckawesomeduck Posts: 87
    edited 2008-12-08 02:48
    Try writing a very small program that runs in slot 0 and writes the slot number to the address 0 of every slot. Then read the first byte from each slot back and check that they go from 0 to 15 matching the selected slot.
    This will provide a cursory exercise of the address lines and you can do it in a very small program with 2 for loops. You might possibly realize something you were doing wrong.

    If it still doesn't work, then update the program to write incrementing values to each location in slots 1-15. Then go back and read from each location, check that the data read = the address modulo 256 and then write back to that address the inverted value of the address. If you ever read back a memory location that does not equal the address of that location, then you have a hardware problem in the memory.
    This will provide a pretty good exercise every address and data line in the memory.

    One question I have is when you say that you "can't read anything from slots 6-15"...what do you mean? Do you always read zeros? Does the processor hang??

    Also, I'm curious what you are making that has so much hard coded data in it?!?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-12-08 06:36
    Gents -

    As I recall, the BS-2e ONLY has 8x2K banks of memory. I'd imagine that's the problem. The BS-2pe has 16x2K banks of memory.

    As a general rule, interpreters won't "choke" on an error like this. It's really more a task of a rather sophisticated syntax checker and parser. There really isn't a reason to have one in PBASIC, as "we" are supposed to know the hardware limitations at the outset.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • awesomeduckawesomeduck Posts: 87
    edited 2008-12-08 15:22
    He stated he is using a 2pe in the original post.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-12-08 15:45
    BettingerJ said...
    Mike,
    the program I use to load in all my data has the following to write data to other program slots, the variable PGMSLOT is incremented until slots 3-15 are all written to, this is just a part of my code, of course. The data lines are part of slot 0 program, they are 19bytes in length for each DATA directive:

    START2:
    FOR B = 0 TO 18
    STORE 0
    READ X, A
    STORE PGMSLOT
    WRITE X, A
    X = X + 1
    NEXT
    IF X = 1634 THEN GOTO START3
    GOTO START2
    There are two things that I am unclear on...in your original post you indicated that you were getting an error from the IDE when trying to load the data.· This cannot happen unless you're trying to load more than 8 program slots, which isn't allowed.· Not sure if that was clarified based on the following replies.

    From the quote above though you seem to indicate differently...that you're populating the remaining banks from the data in slot 0.· You did refer to multiple DATA statements, each 19 bytes in length, however your program seems to only copy the first 19 bytes of slot 0 EEPROM repeatedly.· Is this what you were trying to do?· Currently you will copy the first 19 bytes of slot 0 86 times into the bank specified by PGMSLOT.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-08 16:05
    Chris,
    The locations are copied in groups of 19 bytes, but the address (X) continually increments through 1633. Perhaps there's a problem in the code that he's not shown us.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-12-08 16:18
    Mike, you're right...I read the code twice and still missed that. At first I thought it was a subroutine, but he has X incrementing inside the FOR...NEXT loop and checks for the target value outside of it. I think a nested loop may have been clearer, aside of the missing code setting up X and PGMSLOT on entry. I would definitely have preferred to see all relevent code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2008-12-09 00:41
    John,
    There must be something wrong with the code. The STORE/READ/WRITE method should work just fine.

    FWIW
    The native programming algorithm in the BS2pe does recognize slots 8 to 15 when it receives those numbers embedded in the object file. I have a special version of a Stache that I use for programming DATA into slots 8 to 15 of the BS2pe. In the Stamp IDE I make the DATA files as a separate project directed to slots 0 to 7 and load them into the special version of the Stache. Subsequently it adds 8 to each slot number as it programs the BS2pe, so the DATA ends up in slots 8 to 15, without disturbing slots 0 to 7.

    When Jeff posted the object file format a couple of weeks ago, I went in and hacked the slot numbers in an object file, but ran up against the checksum error when trying to run StampLoader.EXE. Just possibly, it might work with recomputation of the checksum, but . I haven't had inclination to pursue it. It still might not work if the Stamploader does a strong range check of slot numbers.

    The main point is that the stumbling block for loading data into slots 8 to 15 does not lie with the BS2pe itself -- It can accept that data correctly -- The stumbling block is the limitation to slots 0 to 7 in the IDE/downloader.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • BettingerJBettingerJ Posts: 7
    edited 2008-12-11 23:19
    Just got back tonight for a short while to work on this, sorry for the delay. I wrote a small program to read all the data in each program slot sequentially and debug it to the screen for me to verify and yes, all the data was read back from all program slots. When I get the time I will see what I did wrong with the main program (slots 0-2). Thanks for all the support, really appreciate it !
  • BettingerJBettingerJ Posts: 7
    edited 2008-12-16 01:03
    Just to round off this discussion, the problem in my main program and the reason why I could not work with pgmslots 6 and higher was that the following code should not be used with parallax basic;

    IF (47 < CHAR < 51) AND PGMSLOT > 5 THEN ..............

    When changed to the following, the problem went away;

    IF CHAR > 47 AND CHAR < 51 AND PGMSLOT > 5 THEN ...............
Sign In or Register to comment.