Pages: [1]   Go Down
Author Topic: Please help! watchdog ruined my mega2560 board  (Read 1448 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Hi all,

I had my Mega 2560 replaced and bought another one, so I have 2 boards to start
development. My first project is to replace a PIC uController on a refrigerator because it
is unstable (it resets after a few days).

I tried the 2 boards and they worked fine. Until I tested the watchdog on one board.

Here is the code:

Code:
void setup () {
   wdt_enable(WDT0_2S);
   Serial.begin (9600);
}

void loop () {
   wtd_reset ();
   Serial.println (millis());
   delay(500);
}

Now the board is unusable. It resets every 15ms. Googling I find this is a nasty bug.

Without watchdog, Arduino is unusable for real world applications, like my refrigerator.

Now my problem is how to rescue the bricked board. I opened the ArduinoISP and burned
it into my good board. I did the cabling as suggested on the program:

Programmer -> Target board (the 2 are arduino 2560)
50 -> 50
51 -> 51
52 -> 52
53 -> 53

It will not work. Gives me a programmer is not responding error. I also tried to connecr pin 53 on the
programmer board to reset on the target board.

I used Tools -> Programmer -> Arduino as ISP
Then I went to Tools -> Burn Bootloader.

I am using Arduino 1.0.1

This is really frustrating. Please help. I do not have another Atmel programmer available.
Please help me understand what am I doing wrong.

Also, will the bootloader included in version 1.0.1 be watchdog friendly?

I was thinking about connecting:

Host -> Target (ICSP port)
50 -> 1
51 -> 4
52 -> 3
53 -> 5
+5V -> 2
GND -> 6

Will this work?

Documentation on the arduino site is for uno and decimilla... it is so frustrating...



Thank you

Logged

Tucson, AZ
Offline Offline
Sr. Member
****
Karma: 8
Posts: 317
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you put a 100nF Capacitor Between +5V and RESET pin on the working Arduino Mega 2560 to disable auto reset?

Have you tried power cycling the non-working Arduino and then IMMEDIATELY trying to upload a new sketch?
« Last Edit: August 13, 2012, 09:45:59 pm by kd7eir » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That was it! Thank you! I needed the 100nF cap on the host board and pin 53 from the host to reset.

Can you please point me to a bootloader for the Mega 2560 that is watchdog friendly?


Thanks again!
Logged

Tucson, AZ
Offline Offline
Sr. Member
****
Karma: 8
Posts: 317
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

https://github.com/arduino/Arduino-stk500v2-bootloader/tree/master/goodHexFiles

Referenced from here: http://www.desert-home.com/2012/05/arduino-mega2560-wrapping-up-bootloader.html
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It worked like a charm. Thank you very much. I noticed it is smaller.

I wonder why hasn't the bug been fixed over time, as it seems that the bootloader is quite old.

Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys,

I successfully re-programmed the bootloader for my Mega2560 using an Arduino Uno: http://www.gammon.com.au/forum/?id=11635. However, when the watchdog timer kicks in on my Mega2560, the Mega2560 still locks up, and is not able to reboot. Is the 100nf capacitor still required with the new V2 bootloader? Any other suggestion?

Many thanks,
George
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys,

I successfully re-programmed the bootloader for my Mega2560 using an Arduino Uno: http://www.gammon.com.au/forum/?id=11635. However, when the watchdog timer kicks in on my Mega2560, the Mega2560 still locks up, and is not able to reboot. Is the 100nf capacitor still required with the new V2 bootloader? Any other suggestion?

Many thanks,
George

Download and burn this https://github.com/arduino/Arduino-stk500v2-bootloader/tree/master/goodHexFiles

It works fine in mega2560 with WDT. It does not need the 100nF cap to boot.

That cap was needed as in my case I built an atmel programmer with another mega2560 and the problem was that when trying to burn the bootloader, when the the program started, it opened the serial port... but then the mega2560 that acted as the programmer did the reset (without the cap) and the burning would fail. After the cap, the programmer would not reset and the programming was successful.


Hope this helps
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys,

I successfully re-programmed the bootloader for my Mega2560 using an Arduino Uno: http://www.gammon.com.au/forum/?id=11635. However, when the watchdog timer kicks in on my Mega2560, the Mega2560 still locks up, and is not able to reboot. Is the 100nf capacitor still required with the new V2 bootloader? Any other suggestion?

Many thanks,
George

If WTDON=0, the reset is not able to reboot?
Download and burn this https://github.com/arduino/Arduino-stk500v2-bootloader/tree/master/goodHexFiles

It works fine in mega2560 with WDT. It does not need the 100nF cap to boot.

That cap was needed as in my case I built an atmel programmer with another mega2560 and the problem was that when trying to burn the bootloader, when the the program started, it opened the serial port... but then the mega2560 that acted as the programmer did the reset (without the cap) and the burning would fail. After the cap, the programmer would not reset and the programming was successful.


Hope this helps
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 495
Posts: 19036
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

On 20 November 2012 I changed the sketch mentioned to support a watchdog-friendly bootloader for the 2560:

https://github.com/nickgammon/arduino_sketches/commit/dce0d05286c0acdf21f5b5722da0400583852606

The sketch from my site, or Github, should work now.
Logged


Pages: [1]   Go Up
Jump to: