I used wdt in my project and it works well on Arduino Uno with optiboot. So I started to work on my minimum system. I used an Arduino Uno as ISP to burn a brand new Atmega 328p. First,I burned the same bootloader as I used in the Uno. Then I burn the same code. Something strange happened.When the watchdog timer overflowed,the mcu wouldn't restart correctly and it restarted automatically forever. Why it worked when I use USB to burn it but not an Arduino as ISP? Merci.
libertas: Then I burn the same code.
libertas: First,I burned the same bootloader as I used in the Uno.
How did you do this? What bootloader?
[quote author=Nick Gammon date=1437305291 link=msg=2321730] What code?
The code was very simple:
I wanted to restart the mcu by this.It works well when I burned it through the USB serial but not Arduino as ISP.
[quote author=Nick Gammon date=1437305332 link=msg=2321731] How did you do this? What bootloader? [/quote]
I connected pin 11-13 of both Arduinos and pin 10 of the Arduino used as an ISP to rst pin of the target Arduino. I believe I have done that correctly because all the code ran well except the code of wdt.
It was confusing.
Thanks for your reply.
Some bootloaders do not handler the watchdog timer properly. Which bootloader did you install? File name?
[quote author=Nick Gammon date=1437341364 link=msg=2322218] Some bootloaders do not handler the watchdog timer properly. Which bootloader did you install? File name? [/quote]
The filename is "optiboot_atmega328.hex".
I've searched on Google and someone said optiboot could handler watchdog timer well.
In fact,what confused me most is that the timer ran well when I burned it through USB when I chose "AVRISP mkll" .But when I used an Arduino as ISP to burn a standalone Atmega 328p (or an Arduino Uno or an Arduino Nano),it restarted automatically forever but not only once when the following code was executed: