title: ISR(TIMERn_OVF_vect) interrupt not work Atmega 2560
body: <p>i have a problem whith ISR() - this function is not work. I use Atmel Studio 7, USBASP programmer, AVRDude_Prog 3.3 and RobotDyn board with Atmega 2560(Robotdyn Mega +WiFi R3 ATmega2560+ESP8266).</p>
  
  <p>I want read signal from HC-SR04 sensor for mesurment distance. I read datasheet about Atmega 2560 and settings of my timers counters: start from 0 counter up to 4th counter.I tried set up each one setting of interrupts and it's not help me(  </p>
  
  <p>I use LEDs on PORTA for find problem with counters, interrupts and settings. But now i don't have any result.</p>
  
  <p>And this simple code for enable LED, when ISR(TIMER0_OVF_vect) launch not work too, but i copy this from youtube video for test(<a href="https://youtu.be/vl5H_Q1slYY?t=1531" rel="nofollow noreferrer">https://youtu.be/vl5H_Q1slYY?t=1531</a>).</p>
  
  <pre><code>#define F_CPU 16000000UL
  #include &lt;avr/io.h&gt;
  #include &lt;util/delay.h&gt;
  #include &lt;avr/interrupt.h&gt;
  
  #define LED1 0
  #define LED2 1
  
  
  int main(void)
  {
      TCCR0B = (1&lt;&lt;CS00) | (1 &lt;&lt; CS02); //8Mhz/1024/255
      TIMSK0 = (1&lt;&lt;TOIE0);
  
      DDRA = 0xff;
      PORTA = 0b00000100;
  
      sei();
  
      while(1)
      {
  
      }
  
  }
  
  ISR(TIMER0_OVF_vect)
  {
      PORTA ^= (1&lt;&lt;LED1);
  }
  </code></pre>
  
  <pre><code>#define F_CPU 16000000UL
  
  #include &lt;avr/interrupt.h&gt;
  #include &lt;util/delay.h&gt;
  #include &lt;avr/io.h&gt;
  #include &lt;stdio.h&gt;
  
  #define SREG _SFR_IO8(0x3f) 
  
  unsigned char OVF_counter, zamer_1, zamer_T, zamer_t, duty;
  unsigned long t, T, T1, f, num;
  unsigned int rising_1, rising_2, falling;
  
  ISR(TIMER4_OVF_vect)
  {
      PORTA = 0b00001111;
  }
  
  ISR(TIMER0_OVF_vect)
  {
      PORTA = 0b00000011;
  }
  
  ISR(TIMER4_CAPT_vect)
  {
  
  }
  
  void init_timer (void)
  {   
  
      TIMSK4 |= (1 &lt;&lt; ICIE4)|(1 &lt;&lt; TOIE4);    
  
      TCCR4B |= (1 &lt;&lt; ICNC4)|(1 &lt;&lt; CS42);  
  
      TIFR4 |= (1 &lt;&lt; TOV4);
  
      TCCR0B = (1 &lt;&lt; CS01);
  
      TIFR0 |= (1 &lt;&lt; TOV0);
  
      SREG  = 0b10000000; 
  
      SREG  = 0x80;
  
  }
  
  void capture (void)
  {
      PORTB = 0b00001000;
      _delay_ms(10);
      PORTB = 0x00;
  
      rising_1 = ICR4; 
      T=TCNT4;
      TCCR4B &amp;= ~(1 &lt;&lt; ICES4); 
  
      falling = ICR4;
      T1=TCNT4;          
      TCCR4B |= (1 &lt;&lt; ICES4);   
      t = falling - rising_1  ;
  }
  
  int main(void)
  {
      SREG = 0x80;
      DDRL = 0x00;
      DDRB = 0xff;
      DDRA = 0xff; 
      init_timer(); 
  
      while (1) 
      {   
          capture();
  
          if(t &gt;= 1000000)
          {
              PORTA = 0b00000000;
          }
          if(t &gt;= 100000)
          {
              PORTA = 0b00000111;
          }
          else if(t &gt;= 1)
          {
              PORTA = 0b00000011;
          }
          else if(t &gt;= 0)
          {
              PORTA = 0b00000001;
          }
          else
          {
              PORTA = 0b00001111;
              num=0;
          }
  
      }
  
  }
  
  
  
  </code></pre>