/* Interrupt alle 30ms, 1 MHz Systemtakt, 8Bit-Timer 0, Overflow-Interrupt, Wechsel an PB0
Taktzahl:   Phi*Sollzeit = 1Mhz*30ms = 30.000
Vorteiler:  Taktzahl/Werteanzahl = 30.000/256 = 117 aus {1,8,64,256,1024} => 256
Vorsteller: Werteanzahl - Taktzahl/Vorteiler = 256 - 30.000/256 => 139
Probe:      (Werteanzahl-Vorsteller)*Vorteiler/Phi =(256-139)*256/1MHz = 29,95 ms
*/
#include <avr/io.h>
#include <avr/interrupt.h>

int main(){          // Hauptprogramm
  PORTB = 0xff;
  DDRB = 0xff;
  TCCR0B = 4;        // Vorteiler 1: /1; 2: /8; 3: /64; 4: /256; 5: /1024
  TIMSK |= 1<<TOIE0; // TimerOverflowInterruptEnable0
  sei();             // globale Interruptfreigabe
  while(1);          // Endlosschleife
  return 0;
}

ISR(TIMER0_OVF_vect){ // Interrupt Service Routine
  TCNT0 = 139;        // wieder vorstellen
  PORTB ^= 1;           // Ausgang PB0 invertieren (PINB = 1)
}