Hi all,
I need to reset my Arduino Mega ADK (based on ATmega2560) through software. A soft-reset (jumping to address 0) is not sufficient. I learned that I need to use the watchdog timer for this purpose:
wdt_enable(WDTO_8S);
This works fine, but once the board resets, it goes into a reset cycle until I power cycle it.
Therefore I added the following code to disable the watchdog timer after reboot:
void fetch_and_clear_mcusr (void) __attribute__((naked)) __attribute__((section(".init3")));
void fetch_and_clear_mcusr (void)
{
mcusr_mirror = MCUSR;
MCUSR = 0x0;
wdt_disable ();
}
However, this does not work. It keeps resetting itself after the initial watchdog timer reset.
Can anyone help me? Any help is greatly appreciated.
Many thanks in advance,
Michael