Go Down

Topic: Restart Arduino Mega 2560 without Watchdog Timer (Read 4249 times) previous topic - next topic


I am currently using the Arduino Mega 2560 in conjunction with the  LSM303DLM ( http://www.pololu.com/catalog/product/1273 ).  Sometimes the device craps out and hangs the operation of my program. 

I have tried to use the watch dog timer but it doesn't work fully, it never resets the board.  I have also looked into burning a new bootloader to my mega so that it would support the watch dog timer, but when I burned the burned the new bootloader just bricked my arduino( or at least I think i did).

Is there another way of "restarting" the arduino when it hangs up?

Or is there a board out there that fully supports the watch dog timer?

This is for a school project, any help would be much appreciated by myself and classmates!


You can try this little sketch on your Mega to see if the WDT is working properly.  It works on my UNO R2.
Code: [Select]

//  Watchdog Timer Example
#include <avr/wdt.h>

unsigned long ToggleDelay;  //  When this delay grows to longer than the WDT interval the WDT resets the Arduino

const int LEDpin = 13;

void toggle_led()
  digitalWrite(LEDpin, !digitalRead(LEDpin));

void setup()
  ToggleDelay = 1;   // Start with a very short delay
  pinMode(LEDpin, OUTPUT);
  wdt_enable(WDTO_250MS);  // Set watchdog to 1/4 second

void loop()
  toggle_led();   // Blinking goes slower and slower until the WDT causes reset, then starts over.
  ToggleDelay += 5;   // Increase the delay by 5 milliseconds.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


I tried your code on my Mega 2560 and it doesn't seems to work. The LED slows down with blinking until it stops (is lit up constantly). It doesn't seems to reset at all. Are you sure it should work on Mega?


It doesn't seems to reset at all.

While I don't know why there would be a distinction between Uno and Mega, you seem to be talking about hardware reset anyway. There has been recent discussion here.



After 2 hours of reading on Arduino software reset (using watchdog), it seems to me that the watchdog reset does not work. Is anybody there who has software reset working on Mega board?
Or do I need to employ some hardware reset technique?


Jun 05, 2013, 07:28 am Last Edit: Jun 05, 2013, 07:39 am by Galaktika Reason: 1
hi :)

use in the setup:

Code: [Select]
void setup(){
// Arduino Reset Hack http://weblog.jos.ph/development/arduino-reset-hack/
// digitalPin 7 is connected to the RESET pin on Arduino
// NOTE: you CANNOT program the board while they are connected
// by default digitalPin 13 will blink upon reset, so stick an LED in there
digitalWrite(7, HIGH); //We need to set it HIGH immediately on boot
pinMode(7,OUTPUT);     //We can declare it an output ONLY AFTER it's HIGH

then write the pin HIGH to reset your arduino :)

Code: [Select]
void reboot(){

// do somthing useful before shutdown...
// ....
// ....

digitalWrite(7, LOW); //Pulling the RESET pin LOW triggers the reset.

HTH :)

Go Up