Software reset

Hi there,

I thought I had read a post about that but I don't find it anymore... I'd like to reset my board in a program after a while.

Do you have any idea how I can do it?

Thanks, Franck

It is on this forum when I also asked the same question. It was answered by the "Gatorman" from Rugged Circuits.

void software_Reset() // Restarts program from beginning but does not reset the peripherals and registers { asm volatile (" jmp 0"); }

:) :) :)

Thanks... I have another board connected to my Arduino (WiShield), which I'd like to reset also. So I guess it won't work...


You can also use the watchdog timer to self-reset your board as long as you have a bootloader installed that turns it off so it doesn't reset itself forever while waiting for a sketch upload. This has the benefit of also re-initializing all peripherals to default values, while "jmp 0" just starts you program over while leaving peripherals the way they are.

You can reset another Arduino by using a digital output pin and connecting it to the reset line. If you put a pull-down resistor on the line (~1k I'd say) then when the first board goes into reset, the second should do so automatically (since the digital output pin will become an input and the 1k resistor will pull the line low). Then, in your first board's program, make the digital output high to let the second Arduino come out of reset.

Now you want a hardware reset? One option: You could do a hardware reset by connecting a transistor 2N3904 NPN to the pullup reset pin on AVR. The base of BJT via 1k series resistor goes to one of your spare output pins. The emitter goes to ground and the collector goes to pin 1 (reset/10K pullup junction). :)

Thanks guys for your answers. I’d like to test the watchdog solution though. Not sure about my bootloader.

I found that:
CAUTION! On newer AVRs, once the watchdog is enabled, then it stays enabled, even after a reset! For these newer AVRs a function needs to be added to the .init3 section (i.e. during the startup code, before main()) to disable the watchdog early enough so it does not continually reset the AVR.

Here is some example code that creates a macro that can be called to perform a soft reset:

#include <avr/wdt.h>
#define soft_reset()
} while(0)

// Function Pototype
void wdt_init(void) attribute((naked)) attribute((section(".init3")));

// Function Implementation
void wdt_init(void)
MCUSR = 0;


I guess that should work for my Arduino 328?


Useful post, thanks!

Fweens, it seems that the bootloader (at least on my Diecimila) does not disable the watchdog, and it is too late to do it in your sketch with the init3 code.

So I consider that using the watchdog does not work easily.