Program Arduino UNO with ISP with the bootlaoder (Watchdog wdt_disable(); issue)

Hi there!

Is it possible to program an Arduino UNO with ISP with the bootloader?

The bootloader allows to use the watchdog wdt_disable(); function working.

// Comment this linne to ACTIVATE DEBUG
#define DEBUG 1
#define __AVR_ATmega328__
#include <avr/wdt.h>  

void setup() {
  wdt_enable(WDTO_4S);  
  wdt_reset();  
  Serial.begin(1200);
  Serial.println("Watchdog Timer TEST");
  
  /*
  WDTO_15MS
  WDTO_30MS
  WDTO_60MS
  WDTO_120MS
  WDTO_250MS
  WDTO_500MS
  WDTO_1S
  WDTO_2S
  WDTO_4S
  WDTO_8S
  */
}

void loop() { // run over and over
wdt_reset();  
Serial.println("Running GOOD!");
delay(1000);
Serial.println("Always GOOD!");
delay(1000);
Serial.println("Be GOOD!");
wdt_disable();
delay(3000);

Serial.println("WDT disabled");
delay(10000);
Serial.println("YES DISABLED!");
}

When I use the ISP programmer, the wdt_disable(); function is ignored.

When I use it traditionally with USB programmation, it works!

Really I prefer having the function wdt_disable(); working without bootloader but I didn’t find any solution for that…

Regards.

Looking at that code, I'm not sure why the behavior would be different... Optiboot turns off the WDT so that it doesn't reset the board while it's running the bootloader... but I'm not sure how that could produce the observed difference in your code, since the bootlloader isn't running at that time...