Custom baud rate for 32U4 serial port

I’m looking for a way to specify a non-standard baud rate for the serial port on the 32U4 processor, I’m using the #3101 A-Star 32U4 Micro board. I need to read a non-standard serial data stream at 3000 BPS, is there any way to convince the port that’s valid? I see no way in the Arduino to specify anything but the standard baud rates. I’ve also been told my numerous folks that my request is impossible, but I refuse to believe it can’t be done!

What happens if you try calling Serial.begin(3000) on your serial object?

It looks like it should just calculate the clock divisor based on the rate you give it unless maybe it overflows or something but it looks like it shouldn’t: ArduinoCore-avr/HardwareSerial.cpp at master · arduino/ArduinoCore-avr · GitHub

void HardwareSerial::begin(unsigned long baud, byte config)
{
  // Try u2x mode first
  uint16_t baud_setting = (F_CPU / 4 / baud - 1) / 2;
  *_ucsra = 1 << U2X0;

  // hardcoded exception for 57600 for compatibility with the bootloader
  // shipped with the Duemilanove and previous boards and the firmware
  // on the 8U2 on the Uno and Mega 2560. Also, The baud_setting cannot
  // be > 4095, so switch back to non-u2x mode if the baud rate is too
  // low.
  if (((F_CPU == 16000000UL) && (baud == 57600)) || (baud_setting >4095))
  {
    *_ucsra = 0;
    baud_setting = (F_CPU / 8 / baud - 1) / 2;
  }

  // assign the baud_setting, a.k.a. ubrr (USART Baud Rate Register)
  *_ubrrh = baud_setting >> 8;
  *_ubrrl = baud_setting;

Well, as it turns out, it appears not to choke on 3000 baud when I compile it, and after visiting the processor data sheet, it can surely do it. Based on my previous experience with other microprocessor serial libraries, I expected this to be much more difficult! :joy: