Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3.  
  4. volatile uint8_t tot_overflow;
  5.  
  6. void timer0_init()
  7. {
  8. TCCR0 |= (1 << CS02);
  9. TCNT0 = 0;
  10. TIMSK |= (1 << TOIE0);
  11. sei();
  12. tot_overflow = 0;
  13. }
  14.  
  15. ISR(TIMER0_OVF_vect)
  16. {
  17. tot_overflow++;
  18. }
  19.  
  20. int main(void)
  21. {
  22. DDRC |= (1 << 0);
  23. timer0_init();
  24. while(1)
  25. {
  26. if (tot_overflow >= 12)
  27. {
  28. if (TCNT0 >= 53)
  29. {
  30. PORTC ^= (1 << 0);
  31. TCNT0 = 0;
  32. tot_overflow = 0;
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement