Due seems to delete flash by itself

Hi, sorry if this has come up before. I did search the forum for an hour or two and couldn't quite find an answer to this question.

I'm currently building a sort of midi bass guitar controller. The software is almost done and works quite well. The only trouble is that every once in a while, the due completely resets to the point where it appears in device manager like it would after pressing the erase button (i.e. not as arduino due like it would after uploading a sketch). To get it to work again, I simply re-upload the sketch and everything works again, but only for a while.

Furthermore, I have Hiduino loaded onto the 16u2 to act as a USB midi device. Now, on the Hiduino github page, it says that Hiduino is compatible with the due, so I think that whatever is causing this reset has nothing to with the 16u2 or what's running on it. (Or maybe it does? I really have no idea.)

Is there anything on software or hardware (i.e. electrical) level that could cause the due to spontaneously reset or self-erase? Could it have anything to do with the arduino midi library (I had to remove some lines from the header file to get it to compile.) and the way it uses the serial port?

I hope some of you have some ideas to get me started troubleshooting this. My sketch doesn't really do anything taxing on the due and it ran flawlessly with hiduino on the Uno already.

Sooo, any ideas?

The 16u2 drives the ERASE_CMD line, so it must have that line (PC6) set HIGH
and not floating. The ERASE_CMD line goes to the gate of a p-FET and there is
no pull-up resistor on it.

Have a look at the firmware for the Due's 16u2 perhaps?

I wrote the the creator of Hiduino and he said he would need to create a version specifically for the Due.

So, thanks for the tip. :grin: