Arduino Mega 2560 sporadic resets

Hi all,

I have the Problem, that my Arduino sporadically resets it self (or at least restarts the Sketch) when some Push-Buttons of my Project are pushed. I could not yet figure out a schema when it does or does not happen. But I figured out that if I enable some Console Output, the chance for a Reset are somewhat lower.

First some description of my Project.

I tried to do some research on my problem before posting here, but sadly I have not found much information on it.

My Project is to create an electronic Scoreboard for Curling. I used a Arduino MEGA 2650 which is connected 3 MAX 7219 each driving eight 7-set LED. Also connected to the Digital Inputs are 23 Push-Buttons as well as two PWM Outputs. Power is fed through the Power Connector with 7V from a DC/DC Converter.

How the Program should work. Basically all MAX 7219 should be put to sleep. Once any Button is pressed they awake. The Totals (Last MAX having Displays 2&3 for Team A respectively Displays 6&7 for Team B) are set to 0 and displayed. If a Hammer Button is pressed the respective Hammer is lit. Each press on a Push Button of a Team in an end will increase the score for this End. After 8 there is a Roll-Over. Total Scores are live updated. If there is no activity for more than a Timeout (min) Period all Scores are reset and all the MAX are shutdown.

This works quiet well. The Problem is when the Reset Button (Input on Pin 45) or the Team A Button of the 10 End (Input on Pin 43) is pressed there may be a Arduino Reset. I suspect the Problem somewhere in or around the WakeUp() Function. If a Reset occurs when pressing the Pin 43 i can shortly see the Total Segement LED go to ‘0’ before the Board enters the Setup() Function.

First I thought it might be a HW thing, Voltage Drop, Short Circuit anything like this. But now I have loaded the same SW in a standalone MEGA just with 2 Push Buttons connected to those Inputs and I get the same behavior. As written before I assume a Timing Problem as having a lot of Debut Output enabled lowers the amour of sporadic Resets. So far I could not see where in my Code this problem may arise, so currently I suspect one of the used Libs…

The Reset Function at the End of the Sketch is only called from the BoardSetup Function, which can only be entered by pressing both Buttons of the 10th End and the Reset Button. Coincidentally these are the buttons that cause problems. Firstly to enter this function 3 Buttons must be pressed, but the Reset already happens by Pressing just no. Secondly the BoardSetup Routine can not call the softReset immediately as there is a Hard Break before entering this function: All buttons have to be released in order to enter the Board Setup.

When the Reset Button of the Board or one specific Button of a Curling End is pressed, the Board may reset. EEPROM Functions have been temporarily disabled as earlier versions hat some “unlucky” Power supply to the Arduino and sometimes the EEPROM Values where very wrong (I assume because of an uncontrolled Voltage Drop - Arduino was supplied over the unsupported 5V Output Pin) but never the less the problem also happens on a freshly unpacked MEGA Board.

So here I present my Sketch (apologies for the German Comments). Any Hints are most welcome!

Thanx in advance.

ScoreBoard.ino (16.5 KB)

Anybody an Idea what is happening here?

Any hint is most welcome!