Arduino Mega ADK (ATmega2560): Software Reset

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

Anyone, please? :-/

Hello, I'm having the same problem. After a lot of reading the problem seems to be in the bootloader. Flashing the latest version included with arduino 1.0 doesn't solve the problem, at least with the atmega2560.

You can find more info here.... http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1255016475/1

Daneel,
I just update the bootloader with this checkin http://code.google.com/p/arduino/issues/detail?id=181
It’s works!!