I've written a little watchdog firmware that runs on an ATtiny85. The idea of the firmware is to:
- wait 10 seconds after power up and ignore signaling during that time
- after that expects a signal to be pulled low no more frequently than once every 100ms and no less frequently than once every 65 seconds, and failing one of expectations it asserts a reset signal for 10us, and then resets itself resuming at step (1).
Obviously (and arguably gratuitously) I programmed this in Arduino using the ATtiny board description, which maps the pins like so:
My fuse settings are programmed as follows via AVRDude:
avrdude -p t85 -c dragon_isp -P usb -u -U efuse:w:0xff:m
avrdude -p t85 -c dragon_isp -P usb -u -U hfuse:w:0xdf:m
avrdude -p t85 -c dragon_isp -P usb -u -U lfuse:w:0xe2:m
These settings correspond to:
- Internal RC Oscillator @ 8MHz, 6CK/14 CK + 64ms
- Clock output on PORTB4 disabled
- Do not divided clock by 8 internally
- Brown-out detection disabled
- Do not preserve EEPROM memoryy through the Chip Erase cycle
- Watchdog Timer NOT always on
- Serial program downloading (SPI) enabled
- Debug Wire disabled
- Reset enabled
- Self programming disabled.
For the purposes of debugging, it outputs a 100ms pulse width 50% duty cycle square wave during that initial 10 second period, and a 200ms pulse width 50% duty cycle after the initial 10 second period.
For good measure, here's the schematic snippet that goes with this:
The vast majority of the time, the debug signal behaves as described. On very rare occasions though, I've observed a flat low signal on the debug output, no square wave. I've looked at the power and reset lines of the ATtiny85 on a scope in this condition, and there doesn't appear to be any indication of a stuck-in-reset or powered-down condition occurring.
How on earth, then, could my program fail to start up? Could it be because brownout detection is disabled? Should I set the Watchdog Timer always on fuse? I'd really like to understand how this could be happening occasionally.