Program size, bs2
Furcifer
Posts: 3
Chapter 10 of What's a microcontroller, project 2 tasks us with adding a 5th menu option to a sensor array.· I intend to go a bit further and include a lengthy RTTL file for a song.· My question is- what happens if I exceed the EEPROM or RAM capacity of the bs2?· Will it crash, or can damage to the bs2 result?· Thank you
Comments
The Compiler (IDE Run button) will let you know that you've exceeded capacity (Error) and that'll be that.
In the BASIC Stamp, EEPROM stores both the program and also values sent to EEPROM with the WRITE command. If you don't plan ahead, it is possible to keeping writing so much data to your EEPROM that you start to overwrite your program which will cause a crash. You can use the Memory Map to see how much EEPROM space you have for writing during run-time, or you can use a DATA directive for all BS2 models to set aside that space ahead of time and the Editor will catch any potential conflict.
You can read more about WRITE and DATA in the BASIC Stamp Editor Help.
-Stephanie Lindsay
Editor, Parallax Inc.
So while in theory you could change a value in eeprom, finding which value to change would be difficult.
In practice, "self modifying code" is frowned upon. It gets VERY difficult (virtually impossible) to debug, for one thing. And there are alternatives -- that's what subroutines are for, and decision code.
Also, to create a 100 byte program that was "self-modifying" could require a thousand bytes of decision code to decide how to modify the critical 100 byte part.
And yes, what Mike said is correct -- you wind up with certain locations that can't be fully erased.· The symptom you then see is a "compare failure" when you try to program the BS2.