Programming assistance requested
I'm sorry for the multiple posts, I promise that all the information that you all have been providing me has been helping tremendously!
I was hours into a mad coding session and accomplishing a TON of good stuff, when I ran into the dreaded out of memory error.
Unfortunately, this means that either I need to re-evaluate my code or I need to get another chip that has more program space.
I'm using a HomeWork board Rev B, and am looking to solicit information on coding techniques that I can use to minimize code space while maximizing what all I want to do.
Here's the code, I appreciate any suggestions! Keep in mind that this is still unfinished, some features work, but many still have yet to be written.
Thank you.
I was hours into a mad coding session and accomplishing a TON of good stuff, when I ran into the dreaded out of memory error.
Unfortunately, this means that either I need to re-evaluate my code or I need to get another chip that has more program space.
I'm using a HomeWork board Rev B, and am looking to solicit information on coding techniques that I can use to minimize code space while maximizing what all I want to do.
Here's the code, I appreciate any suggestions! Keep in mind that this is still unfinished, some features work, but many still have yet to be written.
Thank you.
Comments
You could move to a different Stamp. The BS2 has only 2K for program storage. Most of the others have at least 16K (like a BS2p), but the 16K is divided up into 2K "slots" which can each contain a program. You can transfer control to the beginning of another slot and you can share variables, but it's not like you can just write a larger program. People have written significant multi-slot programs when they're easily "compartmentalized". Think of slots as overlays.
It sounds like you have big plans and they're probably too big for the Stamp. You may want to consider switching to the Propeller, mostly for its monolithic Spin program memory (32K). You can also use the SX processor and the SX/B Basic compiler which takes a version of Basic very close to that used by the Stamps.
Talking about the BS2p, is it possible to take the big CASE statement and delegate control to those other "slots" for execution? E.g. Slot 0 is the main program, Slot 1 can control LCD0, Slot 2 can control LCD1, Slot3 can control the behavior of the device, Slot 4 can serve for DEBUG messages?
I have been thinking about buying a BOE Bot kit anyways as I was told that the chip-BS2 has more memory than the homework board I have now, but if I can find an SX starter kit, that might be something to think about instead. Do you know if the SX has any kind of serial buffer? (I'm thinking of building a SX-replacement of a common Matrix Orbital display that is based on a PIC controller. :P)
Thank you for your suggestions, I'm going to at least strip out the debug messages and see how much space that saves me in the mean time..
Instead of being 85% full, I'm now more around half! Thank you so much for telling me about the DEBUG statements, I had no idea that they used that much space in memory.
The 24-pin Stamp BS2 is the same functionally as the Homework board. You wouldn't gain anything by switching. It's just that the BOE can take the other Stamp models (and the BOE doesn't come with a specific Stamp).
The SX doesn't "have a serial buffer". Buffering is all done in software and I think there are buffered serial routines available. Ask in the SX forum.
You could vary the debug messages by including a decimal number to identify them (like DEBUG "E",DEC2 5).
Post Edited (Mike Green) : 5/15/2007 2:52:05 PM GMT
Thank you for all your suggestions, I hope to be finishing this within the next week or so. [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
msgPntr = Message1
Then your print routine may look something like:
DO
READ msgPntr, text
IF text = 0 THEN EXIT
DEBUG text
msgPntr = msgPntr + 1
LOOP
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
That's a cool way of doing it, I never knew that the DATA statements worked like that.
Thanks for the tip! Assuming I don't kill myself on storage space, I will put those messages in.
Thank you very much.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support