I have little problem with the code I included at the bottom of the post. The file I include is a .CSV file which contains some integers.
The code works as long as the file doesn't contain too many values. However once the file gets bigger it just stops working.
Basically I would like to include a table with 4000 integers into some project, but I can't get that to work. Even in some really code like the one I included.
Am I overlooking something?
Kind regards;
Budhalol
int myTable [] = {
#include "ward.h"
};
int i=0;
void setup(){
Serial.begin(9600);
}
void loop(){
for (i=0;i<=10;i++){
Serial.println(myTable[i]);
}
}
As your program executes, the amount of SRAM available ebbs and flows. As your definition of the array size increases, available SRAM shrinks to the point where the program can crash. You can get an approximation of the free memory using:
int freeMemory() {
int free_memory;
if ((int)__brkval == 0) {
free_memory = ((int)&free_memory) - ((int)&__heap_start);
} else {
free_memory = ((int)&free_memory) - ((int)__brkval);
free_memory += freeListSize();
}
return free_memory;
}