I've been trying to run some code on an ATMEGA2560, and I've finally boiled everything down to this:
Works
#include "Arduino.h"
#include "HardwareSerial.h"
const char bob[7000] = "Hello\0";
void setup(void) {
Serial.begin(9600);
Serial.println("jshInit...");
Serial.println(bob);
}
void loop(void) {
Serial.println("foo...");
}
Doesn't do anything at all
#include "Arduino.h"
#include "HardwareSerial.h"
const char bob[8000] = "Hello\0";
void setup(void) {
Serial.begin(9600);
Serial.println("jshInit...");
Serial.println(bob);
}
void loop(void) {
Serial.println("foo...");
}
The only difference here is the size of bob. There are no compiler warnings or anything, even if bob is 20000, the Arduino just refuses to work if the bob array is too big.
Does anyone know what's wrong? I'm compiling with the Arduino IDE here, but for my main project I'm using avr-gcc (GCC) 4.5.3, and I tried 4.8.2 as well - same problem on all of them.
The atmega2560 has 256kb flash and 8kB RAM. It could be I'm using all the RAM (but it should tell me if so?), also there is the const keyword on bob which should mean it goes into flash?