3.2" TFT Touch with MEGA - Resetting issue

I have a 3.2" TFT touch Shield Details Here

I have three screens :

MAIN Screen with SETTING and LOGGING buttons.
SETTING Screen with CANCEL and SAVE buttons.
LOGGING Screen with three buttons for Logging and one for HOME.

Functions on each screen work fine and i can go from MAIN to SETTING and also from MAIN to LOGGING. I manage the screen changes by boolean flags inside the Button.JustPressed() code.

However i have an issue where in the loop() function as shown below if I choose SETTING screen the MCU crashes after loading that screen.

But if I comment out the if condition for choosing LOGGING screen, all is fine.

And oddly enough if I choose LOGGING that also works fine even without commenting out the SETTING option !!

void loop(void) {

  if (f_mainScreen) {
    processMainScreen();
  }
  if (f_settingScreen) {
   processSettingScreen();
  }
  if (f_loggingScreen) {
     processLoggingScreen();
  }  
}

And in case you are inclined to see the whole code I have attached it also. Any idea why the RESET happens? Code size and local variables are 13% and 24% of available space.

RR_FPT_Logger_temp1.zip (6.21 KB)

Actually its a problem which is described more in detail HERE

Maybe due to COVID19 and the nature of the problem that i reported it has not elicited any replies so far.

So just to make it more focussed and get a reply here we go :

I have a loop() that just has three "if" conditions that are controlled by three different booleans. And these booleans are set by user choice and result in display of one of three screens. Independently each screen functions as expected.

The loop() is as below :

void loop(void) {

  if (f_mainScreen) {
    processMainScreen();
    Serial.println("Screen1");
  }
  if (f_settingScreen) {
   processSettingScreen();
   Serial.println("Screen2");
  }
   if (f_loggingScreen) {
    processLoggingScreen();
     Serial.println("Screen3");
  } 
}

In the above I can choose Main Screen and Logging screen with no issues. They execute fine. But the moment I choose Setting screen, the screen displays and the MCU crashes and restarts, Just to make sure I started commenting code and the following code runs fine and confirmed by the Serial monitor as I can see "Screen2 " printing on it

void loop(void) {

  if (f_mainScreen) {
    processMainScreen();
    Serial.println("Screen1");
  }
  if (f_settingScreen) {
   processSettingScreen();
   Serial.println("Screen2");
  }
   if (f_loggingScreen) {
//     processLoggingScreen();
     Serial.println("Screen3");
  } 
}

SO the question is simple : The "processLoggingScreen()" causes the MCU to crash even though its inside a if condition. And I have made sure that if condition is never executing ... how is this possible ??

The 2 topics have been merged

@Mogaraghu - you know better than to cross post in different sections of the forum. They have been merged here because this section probably gets more visitors than the Displays section

UKHeliBob:
The 2 topics have been merged

@Mogaraghu - you know better than to cross post in different sections of the forum. They have been merged here because this section probably gets more visitors than the Displays section

Sure. Reason why i linked the other post as a first thing.

Thanks for the merge.

Reason why i linked the other post as a first thing.

It would have been better to have reported the original to the mods and asked for it to be moved but at least you made the duplication public

Ok given the existing situation all around i dont think I am going to be able to get to solve this bug !!

So went ahead and converted the application into a single screen DataLogger and all is fine .... and since the app anyway had a Serial interface with a Utility program running on PC, moved the user parameter editing to the PC utility program. Peace !!