Wrong code prevents upload new and correct sketch

Hi guys,

I have broken my pretty new Mega 2560.

I was playing around with watchdog and I uploaded a broken code.

After that, a couple of seconds after I power the board, the uploaded code stop working. Likely since wdt_reset() is never called.

I have tried to upload a new working code (blink) but I get the following errors:

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
....

How can I have my board working again.

Thank you in advance.

Press & hold reset. Start the IDE download. When it shows "Compiled xxx of 256xxx bytes", releaese the reset button. Might take a couple of tries to find the right release point.

See if this works:

Pause the sketch by pushing the reset button and keeping it pressed.
Upload new sketch (still holding reset button)
Wait until the Arduino IDE reports the binary sketch size in the debug window and then immediately release the button.
Hopefully your sketch will be uploaded before the board locks up.

You might have to try several times to get the timing right.

Edit: CrossRoads beat me to it. We're talking about the same thing.

Hi,

I had tried that procedure yet without success. Since the reset button seems not working (I forgot to mention it in my first post, sorry).

So I tried a little different procedure. I powered the board pressing and holding the reset button and I released it as soon as I saw the sketch size.

After some trials I was able to upload the Blink successfully.

Thank you for your help.