help: (another) stk500_getsync() issue - WDT?

I just encountered what seems to be a fairly common issue, getting the following error when I upload a sketch to my Arduino Mega.

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

My first thought though was that my sketch was responsible. I’ve burned many sketches without problems and was playing around with the watchdog timer. I uploaded the sketch below which I think constantly resets the chip. I’m wondering if this behaviour is now preventing USB comms. Thoughts?

Note: I commented the offending line to prevent others from getting into the same state.

#include <avr/wdt.h>
#include <avr/sleep.h>
#include <avr/interrupt.h>

ISR(WDT_vect) {
  mySerial.println("Watchdog Interrupt!");

void setup() {
  MCUSR = 0;
  // WDTCSR = B01011111;  // I think this is causing a continuous system reset !

void loop() {

One thing you can try is hold down the Reset button until you get the Flashing RX or TX LED when you push "Upload" after that blink, let go and see if it uploads.

I'm not sure if it will work but worth a shot, basically just guarantees you're in the "boot mode" or whatevers required for uploading.

Are you able to load other sketches?

Being stubborn has paid off. I found my problem&answer here…

Managed to fix the issue by plugging the Arduino in, and then quickly hitting the “upload” button for a non-offending sketch.

Thanks for looking.

Its been my experience sofar that if the arduino loses its way such as an array overflow it resets itself . There may be other reasons for this that someone can tell us?

Well, I think this instance is understood in hindsight. In the above WDTCSR was set to System Reset Mode (bit3 = 1). So our logical friend would startup, configure itself to Reset when the Watchdog timer expires, and then promptly reset itself according to its own rules. Repeat.

It would seem self-reset impedes the ability to upload new firmware.

Perhaps there are other ways to induce this. If you know of any examples perhaps we can post and we can debug it.

It would seem self-reset impedes the ability to upload new firmware.

I setup a graphical LCD panel and when trying to upload a new sketch it would not reset. I had to do so manually immediately the compilation process was done.

Removing the reset connection to the panel fixed this so I dont know if this is something similar