Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <avr/io.h>
  2. void tim0(unsigned int);
  3. int main(void)
  4. {
  5. DDRB=0X0F; //making lower nibble o/p port
  6. PORTB=0X00;
  7. TCCR0=0X01; //timer with no prescaler
  8. TCNT0=0X00; //initial count value=0Ɨ00
  9. while(1)
  10. {
  11. PORTB=0X0A; //portb has 0x0a value
  12. tim0(90); //set some delay
  13. PORTB=0X00; //portb value =0Ɨ00
  14. tim0(90); //set some delat
  15. }
  16. }
  17. void tim0(unsigned int x) //sub routine for delay
  18. {
  19. unsigned int i;
  20.  
  21. for(i=x;i>0;iā€“)
  22. {
  23.  
  24. if(TCNT0!=190); //loop till tcnt value becomes 190
  25. TCNT0=0; //reset the tcnt value back to zero
  26. } //continue this loop till i=0
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement