Go Down

Topic: Software reset? (Read 1 time) previous topic - next topic


Is there a way to invoke a reset via program instructions (purely via software)?

And no, I don't want to connect one of the digital pins to the reset pin and bring it low.  This is a hardware solution and from what I can remember it's advised against in the ATmega168 datasheet.


This post has a link to example code to do a software reset using the watchdog timer: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1222941939/4#4


Perfect!  That's exactly what I needed.

Thanks for the help.



Did try the reset code but it actually just ended my code maked it frezze. Any pointers to what i could have done wrong?


Did you get it working?


Here's a simple little sketch that looks for digital pin 2 to go high and then executes the reset.  Make sure you have a pull-down resistor on pin 2 so you don't leave it floating.

Code: [Select]
#include <avr/io.h>
#include <avr/wdt.h>

#define Reset_AVR() wdt_enable(WDTO_30MS); while(1) {}

void setup()
 Serial.println("Sketch startup.");
 pinMode(2, INPUT);

void loop()
 if (digitalRead(2) == HIGH) {


No, I must admit that haven't tried it. If its hanging I wonder if the bootloader needs to be modified to turn the watchdog off. See if you can set the interval long enough to get past the bootloader so you can turn the watchdog off in setup. I would have a go myself but am busy getting the GLCD library working with the ATmega644 chip  ;)


Thanks etracer,

That is the same code i used but it did not work for me but then i am using a ATMega644 and sanguino bootloader that may be the problem.

No high priority on this for me right now mem ...


The above code works fine for me with an ATmega168 - but then I'm using LadyAda's "no-wait" bootloader.  So maybe that's the difference.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131