-  
- #include <avr/io.h>
- #include <avr/interrupt.h>
- 
- 
- 
- 
- void timer_init(void) {
-     // wafeform generation mode bit, see page160
-     // CTC Mode, TOP=OCR2A
-     TCCR2A |= (1<<WGM21);
-     // top value
-     OCR2A = 15625;
-     // set OC2A on compare match - from original code...useless?
-     TCCR2A |= (1<<COM2A0) | (1<<COM2A1);
- 
-     // prescalar: 1024
-     TCCR2B |= (1<<CS22) | (1<<CS21) | (1<<CS20);
-     
-     // if timer2 reaches the value in OCR2A, fire interrupt
-     TIMSK2 |= (1<<OCIE2A);
- }
- 
- 
- 
- 
- #define LED1 PB0
- ISR(TIMER2_COMPA_vect) {
-     PORTB ^= (1 << LED1); // toggle LED1
- }
- 
- 
- 
- 
- int main (void) {
- 	timer_init();
- 	sei();
- 
- 	for (;;) {
- 	}
- }
-