title: Implementing a Timeout in Receive Interrupt for ATMEGA128 uc
body: <p>I am using ATMEGA128 microcontroller and AVR studio for my project. I am using a Receive interrupt ISR_USART0 for receiving 8 bytes of data as a data packet and this interrupt is called after it finishes receiving data the data is used to stimulate some actuators. Here is the Interrupt routine.
  Now i want to add a timeout of 10 ms  in this routine such that as soon as the first byte is received it starts counting the timeout and this lasts for 10 ms and then the software skips waiting for the bytes and returns to the main loop.
  Being a newbie i found very less data on interrupt on implementing  such a timeout inside the interrupt routine...can anyone suggest the best way to implement it.?</p>
  
  <pre><code>ISR(USART0_RX_vect)
  {   
      uint8_t u8temp;
      u8temp=UDR0;
      data_count++;    
      //UDR0=u8temp;
      //check if period char or end of buffer
      if    (BufferWrite(&amp;buf, u8temp)==1){
             Buffer_OverFlow_ERROR=1; TRANSMISSION_ERROR [6]=Buffer_OverFlow_ERROR;
             MT_ERROR_FLAGS_INIT();BufferInit(&amp;buf);data_count=0;REC_ERROR_FLAG=0;}  
  
      if (u8temp==0x58){
           BufferSort(&amp;buf);BufferInit(&amp;buf);
           REC_ERROR_FLAG=0;data_count=0;//PORTA|=(1&lt;&lt;PORTA3);
          }
  
          /*else if{
          REC_ERROR_FLAG=0;BufferInit(&amp;buf);*/
  
  
  }
  </code></pre>