1

Тема: ATtiny 2313 timer

20 Mhz

timer1

 byte i = 0;

void setup() {
 DDRB |=(1<<PB7);
 PORTB &=~(1<<PB7);
  cli();
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1 = 0;
// (20000000/((2499+1)x8))=1000 Hz
  OCR1A = 2499;
  TCCR1B |= (1 << WGM12);
// Prescaler 8
  TCCR1B |= (1 << CS11);
  TIMSK |= (1 << OCIE1A);
  sei();
}

void loop(){}

ISR(TIMER1_COMPA_vect){
  if(i==0)PORTB &=~(1<<PB7);
  if(i==1)PORTB |=(1<<PB7);
  i++;
  if(i>1)i=0;      
  }