Tag Archives: WatchDog

Watch your Watchdog when using DebugWire

The AVR platform has a very handy feature called DebugWire that lets you connect to a chip using only a single pin. Using just this single pin, you can reprogram the chip without having to remove it from the circuit.

To use DebugWire it must be enabled on the chip using a fuse. The only documented downsides to using the DebugWire interface are (1) you loose the use of that pin which is otherwise a reset pin or an IO pin, and (2) the chip will use an additional ~3mw of power even when sleeping.

I think I found another impact of enabling the DebugWire interface – it makes your WatchDog timer take longer to expire.

WDP Setting Actual measured timeout Measured timeout with DebugWire
16ms 16.6ms 21.0ms
32ms 34.1ms 37.4ms
64ms 68.2ms 72.2ms

These tests were all done using the same physical chip at constant temperature (~70F) and constant supply voltage (3.0V).

So it looks like the DebugWire adds about 7ms extra time to the WatchDog timer. This might not sound like a big deal, but at the 16ms setting this more than a 40% error.

In my case it was making me very confused. I eventually gave up trying to figure out what was wrong and adjusted everything to the new timeout so that it would work.

I finally figured it out when I programmed up a production chip without DebugWire enabled to test power consumption and that didn’t work right. ┬áTurning on DebugWire fixed it.

I’ve never seen this issue documented before. Let me know if you find any mention of it that I missed!

Advertisements