for testing the watchdog I setup an ATmega168 (straight from the shop, no fuses changed) on a breadboard with an LED attached to pin PC5.
For the test I used the following sniplet to toggle the pin everytime the watchdog fires which I set to 8 seconds:
Code: Select all
#include <avr/interrupt.h>
#include <avr/io.h>
int main(void) {
DDRC |= _BV(PC5); // enable toggle LED
sei(); // global IRQ enable
WDTCSR = _BV(WDIE) | _BV(WDP0) | _BV(WDP3); // enable WD 8 sec - Datasheet page 56
while(1);
return 0;
}
ISR(WDT_vect) {
PINC = _BV(PC5); // toggle PC5
}
It looks like *always on with flickering* and not on/off every 8 seconds.
Anyone any clue what I missed?