title: How to get out of a USART ISR with an atmega?
body: <p>I have a problem with an atmega 1284p, I wrote this ISR to receive commands via serial.
  If I send an CR or LF to the end of the command, the program works correctly, but if I don't send either of them the program stays in the ISR blocking my program.</p>
  
  <p>Since the ISR disables me all interrupts I don't know how to get out of it!</p>
  
  <p>Can someone help me?</p>
  
  <pre><code>void USART_init(void)
  {   
  UCSR0B |= (1&lt;&lt;RXEN0) | (1&lt;&lt;TXEN0);
  UCSR0C &amp;= ~(1&lt;&lt;USBS0);                  //Stop bits 1
  UCSR0C &amp;= ~((1&lt;&lt;UPM00) | (1&lt;&lt;UPM01));   //Parity check disabled
  
  UCSR0C |= (1&lt;&lt;UCSZ00) | (1&lt;&lt;UCSZ01);    //8 bit data
  UCSR0B &amp;= ~(1&lt;&lt;UCSZ02);             //8 bit data continue
  
  UCSR0B |= (1 &lt;&lt; RXCIE0);
  
  UBRR0H = 0;
  UBRR0L = 64; //9600 baud for a 16MHz Clock.
  }
  
  
  unsigned char USART_receive(void)
  {
  while(!(UCSR0A &amp; (1&lt;&lt;RXC0)));
  return UDR0;
  }
  
  
  ISR(USART0_RX_vect)
  {
  clean_variables();
  
  do {
      cmd[inc] = USART_receive();
      inc++;
  } while ((cmd[inc - 1] != '\n') &amp;&amp; (command[inc - 1] != '\r'));
  inc = 0;                            
  comd = 1;
  split();
  }
  </code></pre>