Hello gang,
I've throught the internet before putting my question but I'm human and sorry if I've the subject where there is a similar question.
So in my program, I got a function which is called only with a combination of buttons.
void serialRequest(int subMenuSelec){
char stringToSend[50];
uint32_t checksum;
switch (subMenuSelec)
{
case 1:
sprintf(stringToSend,"%s",(const char *)pgm_read_word(&serialRquestStr[0]));
Serial.println(stringToSend);
Serial.flush();
break;
case 2:
sprintf(stringToSend,"%s",(const char *)pgm_read_word(&serialRquestStr[1]));
Serial.println(stringToSend);
Serial.flush();
break;
default:
break;
}
}
My understanding is for exemple the variable "char stringToSend[50]" will take some of the SRAM space only when the function "serialRequest" is called.
But when I use the function freeMemory()); in the loop, I can see a reducing of the Freememory when I increase the size of the local variable "char stringToSend" even thought I never do the actions on the buttons to call the function "serialRequest".
my code is quite big (800 lines) so I'm trying to get the clearest possible on my issue so you can help me, don't hesitate to for moreinfo if you need.
Thanks for the answers !
cheers