I am trying to give delay of 0.5 seconds on 13 pin of the arduino using Watch Dog timer interrupt, the code complies and works fine but the led is blinking so rapidly that it seems like it is blinking at a delay of 50ms not with a delay of 0.5 second. Please help. Thanks in advance.
#define F_CPU 16000000UL
#include<avr/io.h>
#include<avr/interrupt.h>
#include<avr/wdt.h>
int main(void)
{
cli();
wdt_reset();
WDTCSR |=(1<<WDP2) | (1<<WDP0);
WDTCSR |= (1<<WDIE);
WDTCSR |= (1<<WDE);
sei();
DDRB |= 0b00100000;
PORTB |= 0b00000000;
while(1)
{
}
}
ISR(WDT_vect) {
PORTB ^= 0b00100000;
}