/*
f = fclk / (N * TCNT)
f = fclk / (N * (256 - TCNT))
fclk = 16 MHz
TCNT = 256

TIMER0
TIMER2 
TCNT = 256 - (fclk / (N * f * S))
S = stevec v časovni prekinitvi

TIMER1
TCNT = 65536 - fclk / (N * f)

16000000
_________
1024 * 256

1024 = 61 Hz
256 = 244 Hz
128 = 488 Hz
64 = 976 Hz
*/


void setup() {
  DDRD |= (1 << PD7);
  cli();
  TCCR2A = 0;
  TCCR2B = 0;
  TCCR2B |= (1 << CS22) + (1 << CS21) + (1 << CS20);
  TIMSK2 |= (1 << TOIE1);
  sei();
  Serial.begin(115200);
}

ISR(TIMER2_OVF_vect) {
  static unsigned long stevec;
  stevec ++;
  if (stevec >= 60) {
    stevec = 0;
    PORTD ^= (1 << PD7);
  }
  Serial.println(stevec);
}

void loop() {
  
}