Leonardo cannot call off the dogs!!

(migrated from the Programming Questions forum...)

I'm running some Leonardo clones. One day as an experiment, on two of my boards, I enabled the watchdog timer with WDTO_15MS. Big mistake.

Now, after I run the bootloader on those boards (but see PS below), my sketch goes into continual reset mode. This does not happen on the boards that were never programmed with WDTO_15MS, even running the identical sketch.

I thought I could fix it by disabling the wdt as early as possible:

#include <avr/wdt.h>
...
void setup() {
  g_mcusr = MCUSR;
  MCUSR = 0;
  wdt_disable();

  ...
}

... but that does not fix things.

Perhaps worth mentioning is that I cannot program the "broken" boards using the USB bootloader (see PS below). For those, I need to use an ISP programmer.

So perhaps the right question is: how do I really and truly disable the watchdog timer in these boards? I think I may need to raze memory altogether (and install a fresh bootloader). But I'm open to suggestions.


PS: More accurately, I believe the boards are going into continual reset mode after the USB reset command, not after loading the code.

What's happening is that the bootloader isn't smart enough to realize the WDT is on and turn it off - so it sits there in the bootloader constantly resetting. You may find that after putting the fresh bootloader onto it, the problem no longer recurrs - I thought the official bootloaders had this problem fixed by now, but some clones don't have the latest version of the bootloader.

You may also be able to upload a clean sketch to them by pressing and holding reset, and then releasing it immediately before attempting to upload (ie, before the sketch starts running and turns on the WDT). Reburn bootloader via ISP will definitely fix boards that have been broken like this.

You may also be able to upload a clean sketch to them by pressing and holding reset

Heh. If my Leonardo clone had a reset button, that would be an option. :confused:

However, re-flashing the caterina-leonardo.hex bootloader via ISP did the trick just fine -- thank you!