Shop OBEX P1 Docs P2 Docs Learn Events
How do you keep BS2e RAM updated in each slot - seeking opinions. — Parallax Forums

How do you keep BS2e RAM updated in each slot - seeking opinions.

vaclav_salvaclav_sal Posts: 451
edited 2011-04-05 10:40 in BASIC Stamp
After committing a major error – not realizing that BS2e has only one RAM - I am now busy programming my BS2e with state machine application. Eventually I may have all 8 slots filled with code.

Right now I got 4 slots working and having a difficult time keeping the RAM in each slot identical.

Would appreciate some commentary on your approach to this development dilemma.

I am finding out that is easier to add variables “on top” - before the Main: function.
Eventually I'll run out of RAM space and planning to use aliases, but not looking forward to do that.
Also I keep some of the common variables ( used in each slot ) in SRAM.
It is rather messy , but works for now.
Vaclav

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2011-04-04 09:54
    I think the following applies in your case; its based on my experience with the BS2sx and BS2px which operate similarly.

    Its not so much that the variables in each slot must be identical (which does help, if you have room), but that you have to understand that you can overwrite them or otherwise change them as you move from one slot to another.

    What I do is use some of the scratchpad memory (which I think you're doing) to save the value of the important variables before leaving one slot. When the program re-enters the slot it gets the current values from the scratch pad before proceeding.

    The other thing to keep in mind is that when you leave a slot, the program resumes at the beginning of the target slot, not where you left off. This is particularly disconcerting when you return to slot 0 and the program restarts ( which it really does). What I do is keep track of whether this return is the first run of the program or whether the program is running as a result of being redirected from another slot. You can then jump over any initialization.

    Once you get onto using all the extra space available, its very handy.

    Cheers,
  • vaclav_salvaclav_sal Posts: 451
    edited 2011-04-05 10:40
    Tom,
    thanks for the reply.
    Looks like we both have a similar approach to this.
    I am finding out that reusing my code is rather challenging.
    I have a stand alone LCD functions which refuse to behave as slot / module functions.

    I am still getting bogus values in some common (RAM) variables
    You are right about using SRAM.
    I feel I have a better control of SRAM based variables.
    I guess one needs to learn to put up with GET / PUT .

    During development the RAM is just too awkward to keep up between modules.
    Next project needs lot more planning to avoid this mess.

    Vaclav
Sign In or Register to comment.