#include <avr/io.h>
void tim0(unsigned int);
int main(void)
{
DDRB=0X0F; //making lower nibble o/p port
PORTB=0X00;
TCCR0=0X01; //timer with no prescaler
TCNT0=0X00; //initial count value=0x00
while(1)
{
PORTB=0X0A; //portb has 0x0a value
tim0(90); //set some delay
PORTB=0X00;
tim0(94);
PORTB=0X05; //portb value =0x00
tim0(94); //set some delaY
}
}
void tim0(unsigned int x) //sub routine for delay
{
unsigned int i;
for(i=x;i>0;i--)
{
if(TCNT0<=199); //loop till tcnt value becomes 190
TCNT0=0; //reset the tcnt value back to zero
}
return; //continue this loop till i=0
}