/*****************************************************
Chip type           : ATmega8
Clock frequency     : 16,000000 MHz
*****************************************************/

#include <mega8.h>

// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
PORTB.1 = 1; // установили 1
TCNT1 = 0; // сбросили таймер
}

// Timer 1 output compare A interrupt service routine
interrupt [TIM1_COMPA] void timer1_compa_isr(void)
{
PORTB.1 = 0; // установили 0
}


void main(void)
{

PORTB=0x00;
DDRB=0x02;

// Timer/Counter 1 initialization
// Clock value: 2000,000 kHz
// Mode: Normal top=FFFFh
// Compare A Match Interrupt: On
TCCR1A=0x00;
TCCR1B=0x02;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1AH=0x27;
OCR1AL=0x10;

// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Rising Edge
// INT1: Off
GICR|=0x40;
MCUCR=0x03;
GIFR=0x40;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x10;

#asm("sei")

while (1)
      {

      };
}
