Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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=0Ć00
- while(1)
- {
- PORTB=0X0A; //portb has 0x0a value
- tim0(90); //set some delay
- PORTB=0X00; //portb value =0Ć00
- tim0(90); //set some delat
- }
- }
- void tim0(unsigned int x) //sub routine for delay
- {
- unsigned int i;
- for(i=x;i>0;iā)
- {
- if(TCNT0!=190); //loop till tcnt value becomes 190
- TCNT0=0; //reset the tcnt value back to zero
- } //continue this loop till i=0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement