Need help with AVR 8 Bit timer

Hi guys, I have written a code for led blink and using a 8 bit timer of micro controller to produce a delay of 1.6384 sec. But as I upload the code to ATmega2560 chip, the led does not blink. I have attached the code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define F_CPU 16000000UL

#include <avr/io.h>

void intzar (void)
{
	unsigned char i = 0;
	for (i = 0; i < 100; i++)		//Makes the delay of 1.6384 sec
	{
	TCCR0A = 0xC2;		//CTC mode is used.
	OCR0A = 0xFF;		//8 bit timer
	TCCR0B = 0b00000101;	//prescaler of 1024
	while ((TIFR0 & 0b00000010) == 0b00000010)
	{
		TCCR0B = 0x00;
		TIFR0 = 0x03;
	}
	}
}




int main(void)
{
	DDRB = 0b10000000;
	
	while (1)
	{
		PORTB = 0b10000000;
		intzar();
		PORTB = 0b00000000;
		intzar();
	}
}
Registered users can post here. Sign in or register to post.