Go Down

Topic: watchdog with the mega does not work? (Read 12828 times) previous topic - next topic

paulinchen

Thanks for your answer, nick.

I think, the problem is now resolved.

Many, many thanks for your great work!

Please update the sketch on your great website also, because i use this place normally.

paulinchen

paulinchen


I think I did an Optiboot loader which does not suffer from the 0xFF issue. I can't recall if that is the one that this sketch uploads or not, but that would explain why I didn't have the issue with the 0xFFs at the end, and you did. Of course in this case you need to upgrade the board which uploads the sketches, rather than the Mega2560 board. :)


I'm not sure I understand you correctly. My English is not so good. Sorry.

But i use only MEGA2560 boards, so i must use as programmer-board also a MEGA2560. You mean, than i use a UNO-board, the problem with the 0xff issue are not present?

paulinchen

nickgammon


Thanks for your answer, nick.

I think, the problem is now resolved.

Many, many thanks for your great work!

Please update the sketch on your great website also, because i use this place normally.

paulinchen


I updated my website.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

nickgammon


But i use only MEGA2560 boards, so i must use as programmer-board also a MEGA2560. You mean, than i use a UNO-board, the problem with the 0xff issue are not present?


You can use a Uno to program a Mega2560 and you can use a Mega2560 to program a Uno. The issue with the 0xFF is a problem in some bootloaders because they assume that memory has been cleared to 0xFF when it hasn't. You occasionally find that people have problems with sketches with a lot of 0xFF in them, for example:

Code: [Select]

int foo = -1;   // this is 0xFFFF


This occurs if this variable is the last one in the sketch (and thus causes trailing 0xFF in the hex file).
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

paulinchen

Hi Nick,
thanks for your declaration of the 0xff-issue, I learn a lot from you.

I give you a little bit more karma  :)

paulinchen

Scott216


I updated my website.

Can you provide a link to this on your website? I'd like to check it out.


chandan0000

How to implement watchdog on arduino mega 2560
Anyone please reply with the code
Because arduino is going to infinite reset loop when watchdog overflow is happening.
In some article I read like we need to upgrade bootloader firmware. How do I know which firmware version I'm using. How to do firmware upgrade.

chandan0000

How to  implement watchdog timer to arduino 2560 because the code which I'm using is going to infinite reset loop when watchdog overflow happens.
I'm flashing the code using arduino  latest IDE below is the code it is working in the positive condition if i comment out reset function in loop then it is going to infinite reset loop.
But the same code worked exactly in arduino UNO
For my project i have to use mega because i need 2 UARTs.
 

#include <Adafruit_SleepyDog.h>

void setup() {
  Serial.begin(115200);
  while (!Serial) ; // wait for Arduino Serial Monitor (native USB boards)
  Serial.println("Adafruit Watchdog Library Demo!");
  Serial.println();

  // First a normal example of using the watchdog timer.
  // Enable the watchdog by calling Watchdog.enable() as below.  This will turn
  // on the watchdog timer with a ~4 second timeout before reseting the Arduino.
  // The estimated actual milliseconds before reset (in milliseconds) is returned.
  // Make sure to reset the watchdog before the countdown expires or the Arduino
  // will reset!
  int countdownMS = Watchdog.enable(4000);
  Serial.print("Enabled the watchdog with max countdown of ");
  Serial.print(countdownMS, DEC);
  Serial.println(" milliseconds!");
  Serial.println();

  // Now loop a few times and periodically reset the watchdog.
  Serial.println("Looping ten times while resetting the watchdog...");
  for (int i = 1; i <= 10; ++i) {
    Serial.print("Loop #"); Serial.println(i, DEC);
    delay(1000);
    // Reset the watchdog with every loop to make sure the sketch keeps running.
    // If you comment out this call watch what happens after about 4 iterations!
    Watchdog.reset();
  }
  Serial.println();

  // Disable the watchdog entirely by calling Watchdog.disable();
  Watchdog.disable();

  // Finally demonstrate the watchdog resetting by enabling it for a shorter
  // period of time and waiting a long time without a reset.  Notice you can pass
  // a _maximum_ countdown time (in milliseconds) to the enable call.  The library
  // will try to use that value as the countdown, but it might pick a smaller
  // value if the hardware doesn't support it.  The actual countdown value will
  // be returned so you can see what it is.
  countdownMS = Watchdog.enable(4000);
  Serial.print("Get ready, the watchdog will reset in ");
  Serial.print(countdownMS, DEC);
  Serial.println(" milliseconds!");
  Serial.println();
  delay(countdownMS+1000);

  // Execution will never get here because the watchdog resets the Arduino!
}

void loop() {
  // We'll never actually get to the loop because the watchdog will reset in
  // the setup function.
  Serial.println("You shouldn't see this message.");
  delay(1000);



In some articles i read like if bootloader firmware is upgraded this problem may occur.
May i know how to know the version of bootloader firmware i'm using. And what is the procedure to upgrade the firmware.

westfw

Do you have a Mega with the new (fixed) bootloader that was discussed in this thread?
If you have a non-genuine MEGA (or one that's just old), that would be ... uncertain.


Go Up