I have tested 4 atmega328 chips with various delay values and I found that
watchdog stopped working when used delay value between 17 - 18.
(2 chips fail when use delay(17) and the others fail when use delay(18))
here is my code.
#include <avr/wdt.h>
void setup()
{
wdt_reset();
wdt_disable();
pinMode(13, OUTPUT);
// digitalWrite(13, HIGH);
// delay(100);
// digitalWrite(13, LOW);
delay(16); // watchdog stop working when delay between 17 - 18
wdt_enable(WDTO_4S);
wdt_reset();
}
void loop()
{
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
wdt_reset();
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
wdt_reset();
digitalWrite(13, HIGH); // set the LED on
delay(5000); // wait for 5 second to test watchdog
wdt_reset();
}
BTW there was no problem even included liquidcrystal library and initialized it.
For safety, operating time in setup function shall not longer than 15 ms for watchdog to work properly.
Hope this will help someone who have same problem as mine.