I started an ATE implementation some months ago and until I reach half of available memory life was a breeze.
Exactly after 1/2 use of available memory Serial.print and Serial.println start to fail, failure modes are change of format or even message suppression.
Environment: processor is an ATmega168, intensive use of SPI for I/O expansion. Version 10 or 11 have the same bug.
Does anyone have any clue or hint? Thanks in advance,
It is the available flash memory. At the end of complation, there is a message: binary sketch size: XXXX bytes (of a 14336 byte maximum). Problems start exactly after 7168 bytes. Until 7167 the Serial.print functions behave ok and deterministically. After 7168 bytes of code several failures occur like: format change or even supression of lines. It seems that the rest of the software is working ok.
I also believe that the original poster is running out of RAM. This same thing happened to me. When my project compiled to about 8700 bytes it would reset and display junk. It turned out that I had vastly over filled the RAM. The problem is that, by default, strings are sent to the unit in FLASH but immediately take up RAM as well. So it's really difficult to determine exactly when the strings will overflow RAM. I should note that this is true of any variable, not just strings. But strings are a quick way to fill things up.
The fix, as someone already mentioned, is to use PROGMEM strings and the appropriate functions to deal with PROGMEM variables.
Unfortunately, I'm away from the hardware and I'll have to wait until monday to test it.
If I got it right you're telling me that the print function throws the data into the UART fifo and it is destroying stack or variable area? This would be a runtime error, according o the symptoms, the problem looks like a compilation error.
But I'll test it. If the problem continues, I will take screenshots and so on. I am a newbie in Arduino, this is my very first project.
The problem is that literals are always stored in RAM (unless you use PROGMEM.) So, it looks like the strings are being stored in flash when you use them in a program but in reality they are allocated within your 1024 bytes of RAM. This can quickly overflow the boundaries. Some of the RAM is allocated to stack and such and you can quite easily overwrite the stack and the rest of RAM with strings.
You can't exactly count on a runtime error. The most likely result of the memory corruption is weird behavior.
Also, keep in mind that you can't really directly use PROGMEM variables in most any function. The usual strategy is to transfer the PROGMEM variable to a buffer in order to use it.