I have a 16x2 LCD (from DFRobot) that I'm driving with I2C connection. It had been working fine for a long time but as my project has gotten bigger, it has started printing garbled text. I haven't been able to reproduce this with a small program. I'm wondering if there is a memory problem. Here is a snipet of the code. I call this routine to display a line of text on the LCD. There are some debugging serial.print commands as well.
This works most of the time but a few calls randomly print jiberish on the LCD. Sometimes, the entire program crashes and restarts. Here is one result showing that I'm passing a valid String object to the routine ("Tilt axis order"). It is received properly. But after the lcd.print line, the String is garbled.
monitor output:
...
receiving: Tilt axis order in LCDLine1, len=15
Tilt axis (jiberish follows but doesn't show up here)
Probably related, one of the variables I read from the EEPROM gets randomly changed even though I don't have any code to change it. It is used as a constant.
So what gets stored in those 32256 bytes? Does that memory have to hold the program, all variables, and EEPROM bytes? Is any reserved for the OS or is that someplace different? Or maybe there isn't really an operating system?
This will be a standalone project so no computer memory will be available. I presume storing things in Flash is only aplicable if you are connected to a computer.
Thanks for the blog posts liudr. In addition to reading http://arduino.cc/forum/index.php/topic,78244.15.html I have successfully moved my strings to PROGMEM and have some free space now. No more garbled LCD messages.
Alright! Just don't get too excited with newly reclaimed SRAM and risk it all on String classes. Using String classes sucks on 2K SRAM. I've seen plenty troubles from using the String class.