01-28-2007, 03:06 AM
Can anybody explain to my exactly what the program slots are and how you would use them?
Post Edited By Moderator (Chris Savage (Parallax)) : 1/27/2007 9:59:02 PM GMT
01-29-2007, 01:09 AM
If you're referring to program slots in the Basic Stamps that have 8x2K eeproms, Nuts and Volts #87 has some info.
01-29-2007, 01:23 AM
The original Basic Stamp II has one program slot, 2k bytes. That limits the amount of program and data you can store. For a program with lots of functions, we had to come up with all kinds of tricks and compromises to fit it all in. We wanted more memory. Due to the tight nature of the PBASIC interpreter, and a desire to keep everything backward compatible, it was not possible for Parallax to simply make a Stamp with one larger memory space. So they came up with slots. That started with the BS2sx, then the BS2e, BS2p, BS2pe and finally the BS2px. Those each have 8 slots for programs, and each slot is a separate 2k byte space where you can store programs and data. To go with that there is a new command, "RUN x", which allows you to switch from a program running in one slot to start running a program in slot x. This is not like a subroutine, where you can automatically call and return, although the physical variable space is untouched when the RUN command executes, so both programs can use the same physical variables. The way the editor works, you have to assign logical variable names in each slot to the physical variables. How and why to do that is one of the recurring questions here. You have to write the program for each slot separately in tabs provided by the STAMPW IDE. (Up to 16 tabs open at a time). You then associate up to 8 programs into one project by a line that you have to enter into the program you want to end up in slot zero. All that is described in the manual under "advancec programming" in the IDE chapter, and under the description of the RUN command.
The BS2p, BS2pe and BS2px introduced another command relevant to the slots, "STORE x". The store command allows a program running in one bank to access directly the data stored in slot x, using READ and WRITE. That is very useful. The BS2pe in fact has 8 additional slots (16 total), and the 8 high slots are available, not for programs, but for additional data and data logging.