Shop OBEX P1 Docs P2 Docs Learn Events
BS2 program memory — Parallax Forums

BS2 program memory

Nikhil VoraNikhil Vora Posts: 7
edited 2005-11-20 19:23 in BASIC Stamp
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

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-11-20 08:23
    Nikhil -

    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
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2005-11-20 12:23
    The BS2 only has 2 KBYTE EEPROM for data storage.

    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
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-11-20 19:06
    1. You could purchase one of the more 'modern' BS2 variants (BS2p, for instance) which has 8K of total memory. You'll have to partition your program into independently 'runnable' banks, howerever -- this doesn't support 'calling' code in other banks.

    2. You could re-factor your program into subroutines, if you haven't already done this.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-20 19:23
    The BS2e, BS2sx, BS2p, BS2pe, and BS2px actually have 16k of program space -- segmented into eight, 2K slots. The BS2pe has an additional 16K (2Kx8) that is available for data only (READ and WRITE instructions).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.