Before I get started, let me briefly state that Arduino is a very, very impressive project. The resources are outstanding, and the hardware is very 'accessible'.
Unfortunately I've been noticing some strange behavior from the Arduino (or compiler?) that seems to be directly related to the size of the global variables I setup. If I define an array in my sketch (which is not small):
unsigned long testArray;
The following code elsewhere in the sketch (in another tab/file, actually) acts up:
Serial.println(HIGH, DEC); // Result: "2"
Serial.print(HIGH, DEC); Serial.print(LOW, DEC); Serial.println(LOW, DEC); // Result: "210"
If I size down the array to only 16, the code prints out the expected values. However, if I then add another array after it (and never access or modify it), I again get the broken results:
unsigned long noProblem; unsigned long causesAProblem;
I have also tried changing the type of the first array to byte (byte testArray; ) and this works fine. Unfortunately I need it to be unsigned long to hold millis() values. I made some effort at cooking up a simple sketch that reproduces the problem, but no luck yet, and there's way too much of my code to post here.
Finally, if I make the second array even larger (128), things go haywire immediately after boot-up (garbage on the serial output).
It seems clear that this is causing something to overrun it's buffer, but I don't know what. I find it particularly odd that even the unreferenced array excites the behavior. Am I just using up too much memory? I have a few other arrays, but my sketch size is only 7130 bytes ("14336 max").
Environment: Arduino NG rev.C USB, Mac OS X 10.4.9.