Тема: Atmega8 timer
TIMER 1
4 MHz
bool led_stat = true;
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
cli();
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
// (4000000/((15624+1)x256))=1 Hz
OCR1A = 15624;
TCCR1B |= (1 << WGM12);
// Prescaler 256
TCCR1B |= (1 << CS12);
TIMSK |= (1 << OCIE1A);
sei();
}
void loop(){}
ISR(TIMER1_COMPA_vect){
digitalWrite(13, led_stat);
led_stat = !led_stat;
}