This is peculiar.... I wrote a dead-simple program, that simply would not behave rationally. I eventually narrowed the problem down to use of an array of pointers to char arrays. I created the attached minimum case to demonstrate the problem.
All this does is define, then print, several arrays of char *. If I add a single additional pointer to any of the arrays, the printing gets massively hosed. It is only reporting 68% memory usage, so it does not seem to me that should be a problem but apparently it is! Any usage over 68% causes Serial.print output to get whacked.
I am running on a 168-based Nano, using IDE 1.8.4.
enum cmds
{
CMD_TBL, // TBL=OFF/ON/UP/DOWN/PUSH
CMD_HEAT, // HEAT=ON/OFF
CMD_RES, // RES=ON/OFF
CMD_VAC, // VAC=OFF/1/2/BOTH/
CMD_START,
CMD_STOP,
CMD_TUP,
CMD_TDOWN,
CMD_TPUSH,
CMD_THEAT,
CMD_TPULL,
CMD_TFAST,
CMD_SHOW,
CMD_NCMDS
};
char *keys[] =
{
"TBL",
"HEAT",
"RES",
"VAC",
"START",
"STOP",
"TUP",
"TDOWN",
"TPUSH",
"THEAT",
"TPULL",
"TFAST",
"SHOW",
};
char *crap[] =
{
"11111",
"22222",
"33333",
"44444",
"55555",
"66666",
"77777",
"88888",
"99999",
"AAAAA",
"BBBBB",
"CCCCC",
"DDDDD",
"EEEEE",
"FFFFF",
"GGGGG",
"HHHHH",
"IIIII",
"JJJJJ",
"KKKKK",
"LLLLL",
"MMMMM",
"NNNNN",
"OOOOO",
"PPPPP",
"QQQQQ",
"RRRRR",
"SSSSS",
"TTTTT",
"UUUUU",
"VVVVV",
"WWWWW",
"YYYYY",
"ZZZZZ",
"011111",
"022222",
"033333",
"044444",
"055555",
"066666",
"077777",
"088888",
"099999",
"0AAAAA",
"0BBBBB",
"0CCCCC",
"0DDDDD",
"0EEEEE",
"0FFFFF",
"0GGGGG",
"0HHHHH",
"0IIIII",
"0JJJJJ",
"0KKKKK",
"0LLLLL",
"0MMMMM",
"0NNNNN",
"0OOOOO",
"0PPPPP",
"0QQQQQ",
"0RRRRR",
"0SSSSS",
"0TTTTT",
"0UUUUU",
"0VVVVV",
"0WWWWW",
"0XXXXX",
"0YYYYY",
"0ZZZZZ",
"1AAAAA",
};
void setup()
{
while (!Serial)
;
Serial.begin(115200);
Serial.printf("Vacuum Former Starting...\n");
for (int i = 0; i < cmds::CMD_NCMDS; i++)
{
//delay(100);
Serial.printf("%s\n", keys[i]);
}
for (int i = 0; i < sizeof(crap)/sizeof(char *); i++)
{
//delay(100);
Serial.printf("%s\n", crap[i]);
}
}
void loop()
{}
Regards,
Ray L.