BS2 program memory
Nikhil Vora
Posts: 7
What would be the easiest way to store more code in the BS2 memory? I have some code and the tokenzer says that the EEPROM is· full.
I would appreciate any help in this matter.
-Nikhil Vora
I would appreciate any help in this matter.
-Nikhil Vora
Comments
Other than compacting your existing code there isn't much you can do on a BS-2 since it has no program banks, like most of the more advanced Stamps do. None of the present Stamps support external or additional memory.
If you have lots of redundant code which does the same thing, or almost the same thing, turn it into a sub-routine and use GOSUB. This will save a good deal of EEPROM memory.
Make sure you're using the smallest size variable: don't use a word when a byte will do, don't use a byte when a nib will do, etc. The first impact this will have is to reduce the amount of RAM variable space allocated, and that's a precious commodity as well. The second thing it may do is to reduce the program code space, which is the original goal.
Remove any/all DEBUG statements. Grab as many fields as possible in each SERIN, rather than using multiple SERIN's. There are memory tradeoffs between multiple IF ... THEN structures, and the use of SELECT. You may have to try both constructs to determine which uses less memory in your particular program.
I'm sure others will mention additional methods, but there are a few to get you started.
Regards,
Bruce Bates
Here is a post showing how to connect a 4KBYTE EEPROM to the BS2 for extra data storage. You will never get more variables RAM but this might foot the bill and are available from Parallax. As Bruce stated before, reuse variables at their minimal size and subroutines.
However you may want to look into the SX28 (meaning new development board $200+ cost but $5 cheaper chips) or another BS2 variant with I2C and (8· x 2KBYTE) EEPROM banks such as the BS2PX at $80.
http://www.parallax.com/dl/docs/books/sw/exp/sw32.pdf
2. You could re-factor your program into subroutines, if you haven't already done this.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax