Problem using watchdog timer on Attiny4313

The following code works on Nano and Pro Mini, but not on bare-bones Attiny4313 with LED attached to pin 16 (D13). Can anyone see why? The LED on 4313 comes on and never turns off. Can anyone try it on any other tiny? I should mention that the Samples => Blink code works fine on 4313.

The code below that I have the problem with is essentially “blink”, except that the delay has been replaced by the watchdog timer, which toggles the state of the LED on every time-out, when the interrupt service routine is called.

To make the code work across the MCUs, I have renamed the MCUR to MCUSR and WDTCR to WDTCSR in iotn4313.h I hope that did not affect the functionality…

byte LED = 13;
boolean LEDon = true;

void setup()
{
   pinMode (LED, OUTPUT);
   digitalWrite (LED, LEDon); 

   // Set up and turn on the watchdog timer.
   MCUSR &= ~(1<<WDRF);               // Clear the watchdog reset flag
   WDTCSR |= (1<<WDCE) | (1<<WDE);    // Set WDE and WDCE - must be done in one operation; writing 1 to WDE starts the timed sequence
   WDTCSR = B00000110;                // Set the watchdog timeout prescaler to 1 s; must be done within 4 cycles from writing 1 to WDE
   WDTCSR |= _BV(WDIE);               // Enable the watchdog timer interrupt.
}



ISR(WDT_vect)   //  Watchdog Interrupt Service.
{
   LEDon = !LEDon;
   digitalWrite (LED, LEDon); 
}



void loop()
{
}

With this code the LED on Nano or on Pro Mini blinks at 1 s rate, but on Attiny4313 it comes and stays on, never blinking.

I am using Arduino IDE 1.0.4 with WinAVR updated to the 20100110 (gcc-avr 4.3.3).

Edit:

The WDT_vect is named differently on the t2313/4313. It should be WDT_OVERFLOW_vect.

This works correctly on my t4313.

That was the problem - renamed vector. Now it works for me, too. Thanks HiDuino! (Took me a few days to gain control over burning fuses through ISP)

iotn4313 that comes with WinAVR20100110 has named registers differently from both the chip datasheet and from the so-far used nomenclature for other MCUs, 328p most notably; PCINT_A/B/D instead of PCINT0/1/2, WDCR-WDCSR, EIFR-GIFRand such... Extra bits in come registers - PCIE5, PCIF5 in GIMSK and GIFR... Some possible typos - BPDSE/BODSE... The iotn4313.h remains the same in avr-gcc 4.8, which makes me wonder about my view of the datasheet - i/o header relationship. I'll try to get in touch with gcc avr development crew to gain the insight.

I now have a problem turning the watchdog off on either the 4313 or the 328p, but I'll start a separate thread on the issue, as soon as I put a sample code together.

EDIT: Never mind the note on having problem turning the WDT off - the sample code from the datasheet works fine.