/* 8 MHz Systemtakt, 16Bit-Timer 1, Overflow-Interrupt, Blinken mit 1 Hz an PB0
Taktzahl:   Phi*Sollzeit = 8Mhz*500ms = 4.000.000
Vorteiler:  Taktzahl/Werteanzahl = 4.000.000/65536 = 61 aus {1,8,64,256,1024} => 64
Vorsteller: Werteanzahl - Taktzahl/Vorteiler = 65536 - 4.000.000/64 = 3036
Probe:      (Werteanzahl-Vorsteller)*Vorteiler/Phi =(65536-3036)*64/8MHz = 500 ms
*/
#include <avr/io.h>
#include <avr/interrupt.h>

int main(){          // Hauptprogramm
  PORTB = 0xff;
  DDRB = 0xff;
  TCCR1B = 3;        // Systemtakt durch 64
  TIMSK |= 1<<TOIE1; // TimerOverflowInterruptEnable1
  sei();             // globale Interruptfreigabe
  while(1);          // Endlosschleife
  return 0;
}

ISR(TIMER1_OVF_vect){ // Interrupt Service Routine
  TCNT1 = 3036;       // wieder vorstellen
  PORTB ^= 1;           // Ausgang PB0 invertieren (PINB = 1)
}