I have a sketch which at about 75% of Uno flash/ram usage gives inconsistent output.
Running the same sketch on a Mega gives consistent output.
Is there a rule of thumb for max sketch size relative to flash/ram memory size?
I have a sketch which at about 75% of Uno flash/ram usage gives inconsistent output.
Running the same sketch on a Mega gives consistent output.
Is there a rule of thumb for max sketch size relative to flash/ram memory size?
75% of Uno flash/ram
Which ?
I like '1284P for its large SRAM - 16K.
I've written code with arrays up to 14625 bytes.
AWOL:
Which ?
Do you seriously mean you did not understand that to mean both?
Sketch uses 24,738 bytes (76%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,569 bytes (76%) of dynamic memory, leaving 479 bytes for local variables. Maximum is 2,048 bytes.
CrossRoads:
I like '1284P for its large SRAM - 16K.
I've written code with arrays up to 14625 bytes.
Are these custom boards?
aisc:
I have a sketch which at about 75% of Uno flash/ram usage gives inconsistent output.
Running the same sketch on a Mega gives consistent output.Is there a rule of thumb for max sketch size relative to flash/ram memory size?
The rule of thumb is: Your FLASH usage is fine as long as it does not go above 100% but your SRAM usage has to leave room for your stack and heap which will depend on your execution path. If your sketch goes wonky try reducing your SRAM usage.
If you have any .print("String constant"); calls the easiest fix is to change them to .print(F("String constant")); to keep your string constants from being stored in both FLASH and SRAM.
Are these custom boards?
Yes, I offer them in several form factors, see my webpage for pics, schematics, etc.
http://www.crossroadsfencing.com/BobuinoRev17/
aisc:
Do you seriously mean you did not understand that to mean both?
With it written as a ratio?
Yes.
johnwasser:
The rule of thumb is: Your FLASH usage is fine as long as it does not go above 100% but your SRAM usage has to leave room for your stack and heap which will depend on your execution path. If your sketch goes wonky try reducing your SRAM usage.
If you have any .print("String constant"); calls the easiest fix is to change them to .print(F("String constant")); to keep your string constants from being stored in both FLASH and SRAM.
Thanks - I am already using serial.print(F("")).
AWOL:
With it written as a ratio?
Yes.
Obviously different backgrounds...
I would interpret flash:ram as a ratio.
I would interpret that as the poster being confused about the difference between flash and ram, and hence cause for further questioning. That both flash and ram were 75% would be the last thing I'd expect - a single clarifying word like "both" in there would have done a great deal to clarify things for people.
If you're using the String class anywhere, try to get rid of it and use normal C strings (ie, char arrays), the String class has a lot of overhead, and where SRAM is tight, it's very good at causing problems.
aisc:
<...>
Is there a rule of thumb for max sketch size relative to flash/ram memory size?
A good question, but in my years of experience with the Arduino, there is no "rule of thumb" for flash usage to SRAM. A small sketch can consume SRAM and a huge sketch can run in precious little SRAM.
Ray
I've done programs where I used arrays, and expanded the size of the array until the program crashed, then backed off some (just a few bytes) until it stopped crashing, and used that as the final array size.