Arduino Mega2560

Hello, I am building a Robot-System. For the drive parts I use an Arduino Uno. For the Arm and all other parts like 2 Cameras, EMIC2 Text to Speech, Voice recognition shield and Nextion display with Touchscreen I use an Arduino Mega2560. Until now all is working. My problem is, that I use about 85% of the SRAM. 5% more and the sysem will not work properly (i have tested it). So my Question is: Exist an Mega with more than 8 Kb SRAM? Can I use another board with more than 8Kb SRAM and nearly the same features like my Mega2560 has? Is it possible to change the SRAM? Exists a special shield for mey problem?

Please be so kind a send my an answer (with some good tipps, if possible).

Thank you very much.

Best regards

Peter Dambrowsky peterdambrowsky@gmx.de

The 1284p is the only AVR microcontroller with more than 8k of SRAM - it's got only 128k of flash though. Not used in any official boards, but many unofficial boards do (Crossroads on these forums sells some, as do many others). Board package for them is https://github.com/MCUdude/MightyCore

Have you done all the SRAM optimizations? F() macro, putting arrays of constants in PROGMEM, etc?

It is hard to help optimize code that we can't see. The general advice would be to use the F macro where ever there are string literals being printed (to Serial, LCD, etc). Another is to use the const keyword to put constants in Flash.

Put the text into progmem then? Or does the library not support that?

If you post your sketch we could help you with optimization. But we can't optimize code we can't see.

You can use progmem string at many places instead of normal string. It saves the SRAM. Read this article: PROGMEM and especially F() macro part.

...
 if (! rtc.isrunning()) {
//    Serial.println("RTC is NOT running!"); /* string is copied into SRAM */
    Serial.println(F("RTC is NOT running!")); /* string stays in FLASH  */

Ok. Now all is OK. I used your Tipps and installed PROGMEM and Serial.println(F("TEST")) f.e. in my sketch. I got about 30% more space in my SRAM. That´s what I wanted.

One more time thank you very much for the Tipps. You never should stop learning more :-)

A forum like this is really good.

Best regards

Peter