Shop OBEX P1 Docs P2 Docs Learn Events
What limits the variables in BS2p — Parallax Forums

What limits the variables in BS2p

gncguygncguy Posts: 35
edited 2008-02-26 04:41 in BASIC Stamp
I was programming my Boe-bot and trying to put more sphiscated algorithms.· I am interested in adding digital filters to the code.· but I got an error message saying there were too many variables.· I have looked at the Stamp comparison page and it mentions memory but it does not mention a limt on the number of variables.· I had 8 word length variables.· How can you work with 15 pins with only 8 variables?· doe using byte length variables allow you to have more variables?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-02-26 02:41
    You need to try reusing variables where possible. Attach your code and I'm sure some of us here could help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • NewStamperNewStamper Posts: 33
    edited 2008-02-26 02:49
    I am quite new to BS2, but you can look at your memory map and perhaps figure out how the variables are loading there.
  • NewStamperNewStamper Posts: 33
    edited 2008-02-26 02:55
    Share a common global variable and let both tasks do its thing. See if this would help you.
    http://forums.parallax.com/forums/default.aspx?f=25&m=112788
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-26 03:57
    There's a section of the PBasic manual that discusses variable memory allocation in the section on architecture. On all the BS2 Stamps, you've got 13 word variables that can also be accessed as 26 byte variables. They can also be accessed as 4-bit nibbles and individual bits. The various I/O registers (INS, DIR, OUT) are 16-bit and bring the total number up to 16 words.

    There's some special additional storage on some Stamps. The BS2p series have "scratchpad RAM" in different amounts. This is volatile storage that can be accessed one byte or one word at a time and some locations have special functions (see the manual) as well as being accessible with some of the I/O commands like SERIN and SEROUT.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-02-26 04:41
    gncguy -

    In your post you said you had "8 word length variables". You MUST have had other variable space assigned, since you ought to be able to assign up to 13 WORD length variables with no problem. As Mike pointed out there are a total of 26 BYTES in RAM, and each WORD is 2 BYTES long; thus 26 / 2 = 13 WORD sized variables.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Genius is one percent inspiration and ninety-nine percent perspiration."

    Thomas Alva Edison
Sign In or Register to comment.