USART RX Interrupt stuck

Trying to integrate USART RX interrupts to help with input buffering. Unfortunately I hit a roadblock that I have been unable to find any information on. I can set up the ISR and trigger the routine correctly, however, the processor never exits the ISR and it seems to just loop inside of that block of code endlessly

Here is the code I’ve been testing:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
 
#define FOSC 16000000

#define BUAD_UART_0 300

#define MYUBRR(x) ((FOSC / 16 / x) - 1)

ISR(USART0_RX_vect) {
  PORTB |= (1 << 5);
  PORTB &= ~(1 << 5);
}

int main() {
  DDRB |= (1 << 5);

  sei();           
  
  UBRR0=MYUBRR(BUAD_UART_0);
 
  UCSR0B|=(1<<RXCIE0)|(1<<TXEN0)|(1<<RXEN0);
 
  UCSR0C|=(1<<UCSZ01)|(1<<UCSZ00);

  while(1) {
  }

  return 0;
}

Does it look like I’m missing anything obvious? This is for an Mega2560 by the way. Do I need to clear a bit inside the ISR? Is it just crashing?

I did some testing with the above code and captured the oscilloscope. I’ll try to attach that file If it will help explain what is going on. You’ll be able to see the test pin going crazy after the RX byte is received.

Any help is very appreciated,

Thanks

TEK00001.png

check out hardwareserial_private.h it's not stuck inside the the ISR it just keep firing continuously until you read the buffer. You need to read the available byte as the interrupt does in ths lineunsigned char c = *_udr;

Thanks!