0

I followed an example link for WDT. Code was copied as is, and uploaded to Nano successfully.

Now- when I wish to upload another code, I get an error message saying avrdude: stk500_recv(): programmer is not responding.

Is it possible to undo it ?

code:

#include <avr/wdt.h>

#define led 13 // pin 13 is connected to a led on Arduino Uno

void setup()
{
  pinMode(led, OUTPUT);      // set pin mode
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                // wait for a tenth of a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                // wait for a tenth of a second
}

void loop(){
  wdt_enable(WDTO_15MS);     // enable the watchdog
                             // will fire after 15 ms without reset

  while(1)
  {
//     wdt_reset();          // uncomment to avoid reboot
  }
}
  • change the bootloader in Nano to a new one, which doesn't have this problem. and you shuold enable wdt in setup and reset it in loop. – Juraj Nov 3 '18 at 21:05
1

One of the things with the watchdog is that after a watchdog reset it remains active. It has to specifically be turned off - and the bootloader doesn't (IIRC) normally turn it off.

If the timeout is too short (shorter than the time taken to upload new code) the watchdog will reset the chip while you're uploading.

The only way to turn it off is to physically remove power from the chip, and make sure that the loaded sketch never runs.

  1. Select the board / port etc ready to upload
  2. Unplug the board
  3. Hold the reset button in
  4. Plug in the board
  5. Press upload on the IDE 6 Just as avrdude is about to run (that's the program that does the actual uploading) - just as the compiling has finished, release the reset button

If you did it right you should be able to upload properly. If not, you will have to try again from step 1.

2

If the WDT program is running when you try to upload a new one, it may be blocking the bootloader. Try holding the reset button while you click the the IDE's upload button, releasing the reset once you see avrdude launch. It may take a few tries to get the button-dance just right.

Update:

what is avrdude ?

It is the program on your PC that uploads the compiled image to the Arduino. You'll see it running in the lower pane of the Arduino IDE.

  • what is avrdude ? – Guy . D Nov 3 '18 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.