Arduino Uno Too Much Error Baud Rate Hardware Serial [375k]

Hello all,

I've been working tirelessly for the last several weeks on creating a Serial connection (UART) between an Arduino Uno and another device at 375k baud. The other device is established and custom-created and has been solid and reliable for years. Basically, the system as it currently stands has two different components running at clock speed 6MHz. They are connected by a UART Serial connection, using baud 375k (0% error). This connection is reliable and works without fail.

I am trying to insert a Arduino Uno in between the two components: so the first component sends data to my Uno, which then passes this data along to the second component. Because both components are running at 375k, my Uno must also run at 375k to be able to interface with these components.

My first goal was to receive data from the first component and display it on an LCD shield. So far, I was able to do so with a Leonardo at 16MHz with relative success, but the bits sent latest in the transmission would often become jumbled. Based on another forum post, I determined that my Leonardo's error rate at 16MHz with a 375k baud rate was just barely beyond what the original system could handle. The Leonardo was handling the first few bits in the transmission correctly, but the later ones would get mixed.

To test this theory, I finally got access to an oscilloscope and I decided to read signals from both the first component and my Leonardo to see how long each bit was held. I repeatedly sent 0x55, because this would alternate bits and make it easier to read and calculate. From the first component, I got a bit-width of 2.67usec (nearly exactly the expected value). I checked my Leonardo at 16MHz and got 2.48usec (3.7% error). According to documentation for the first device, 1.5% error is the maximum error that the system can handle without data being corrupted. So this seemed to prove my theory.

For there, I grabbed an Arduino Uno using an external oscillator of 12MHz. According to the formulas provided in the datasheet for the Atmega328p, I confirmed that a 12MHz should work with a 0% error for a baud rate 375k. This was also fair to assume because the 6MHz device I was using had a 0% error and 12 is simply a multiple of 6, so the process of dividing the clock signal should be nearly identical.

Here are my calculations that suggests that there should be a 0% error for the Atmega at 12MHz:

UBRRn = (fosc/(BAUD16)) - 1
UBBRn = (12M/375k
16) - 1
UBBRn = 2 - 1 = 1 (A whole number is a good sign!)

error = ((BaudRateclosest match/BaudRate) - 1)2 * 100%
error = ((375k/375k) - 1)2 * 100%
error = (1-1)2* 100%
error = 0% 0% Error!

From here, I checked my Arduino Uno using the oscilloscope and determined each bit was held for 2.0usec. This is nearly 25% error (when I expected 0%)! This does not make sense to me. Out of curiosity, I tried some alternative baud rates on the Arduino side to see what the Uno outputs. A baud rate of 280,900 yielded a bit width of 2.48usec (better but not good enough). A baud rate of 275,000 yielded a bit width of 2.98usec (this is too large). I could not get anything better in between these two values (as I expected with a clock speed like this).

So in summary, this doesn't make a whole lot of sense to me because the Atmega328p should be able to perfectly handle this baud rate when run at 12MHz. Does anyone have any idea why this is failing? I feel like the Arduino libraries that sit above the Atmega328p's Hardware Serial should have no bearing on this because it is a hardware defined protocol, but I could be wrong.

Any ideas or insights?

Thank you all in advance!

Sorry, I don't understand the following things:
First: how can you know the correct message (to calcolate the errors)? If you can't display a message correct you have to calcolate it, but if you can calcolate the message why you try to connect a display?
How can you know that Arduino, witch the Serial library, can arrive at this speed?

Hi Silente,

1.) The error rate I am referring to is measuring the accuracy of the generated baud rate I am using, not the accuracy of the data in the transmission itself. I'm not measuring how many bits are incorrect, but instead, how accurately my clock is generating the baud rate required. I measure that error using A.) the formulas provided to me in the Atmega datasheet, and B.) comparing expected time-per-bit at this baud rate and the actual time-per-bit (as measured using an oscilloscope).

2.) I know the Atmega328p's (the onboard processor for both the Uno and Leonardo) datasheet specifically states that it can manage this baud rate at even lower speeds. I know that the Arduino's micros() and mills() function may not work with a 12MHz processor but that should have no bearing on my work because A.) the processor's HardwareSerial performance is not dependent on the Arduino libraries (in fact, the opposite dependency is true) and B.) I do not need the micros() or millis() functions for the rest of my program.


Seems to me you are creating a monster to do a simple read on an oscilloscope with a calibrated time base.

You did set the Arduino clock to some standard, did you not?



For the given Bd (375000), the bit period is : 2.67 us. In your oscilloscope, you are measuring 2.0 us. On the other-hand, there is no data communication problem between the Transmitter and Receiver.

Have you known the precision and accuracy of your oscilloscope? Please, get those data from the Technical Manual of the scope and interpret the measured value of the scope in a rational way. I hope that you will be satisfied.

where did you find an uno with a 12mhz oscillator? It’s normally 16MHz.
Some clones have a 12MHz crystal, but that’s for the usb chip...

The same question pressed me a lot -- how the OP can have a UNO with 12 MHz crystal for the ATmega328P. Later on, I started to believe that the OP had removed the original 16 MHz crystal, and he had placed a 12 MHz crystal in that place to arrive at the Bd = 375000.

I checked my Arduino Uno using the oscilloscope and determined each bit was held for 2.0usec.

This is exactly the rate that you'd expect to see if the AVR were actually running at 16MHz: 500kbps matches up with a UBRR of 3. 375kbps (at 16MHz) is exactly half-way between 250kbps (UBRR=4) and 500kbps (UBRR=3)

Hmm. I found your Other posting.

Did you perhaps change the wrong crystal?

Hi all,

Thank you for all of the responses! I appreciate it!

To sort of answer you all as efficiently as possible, let me summarize a bit:

Basically, I was getting substantial error with my Uno trying to run a 375000 baud rate using a 16MHz clock. So I referred (based on some forum advice) to the Atmega datasheet and discovered that there was a high expected error rate for that speed. However, I knew that the system I was trying to interface with used a 6MHz processor with 0% error on 375k baud. This made sense because this divided to a whole number (16). Based on this, I reasonably expected that if I set up my system at 12MHz, my divisor could be 32 and all would be well in terms of baud rate generation.

So I uninstalled what I thought was the 16MHz oscillator for the Atmega328p, and replaced it with a comparable 12MHz oscillator. Then I tested that system and the Uno no longer appeared as a device on my computer. I used another Arduino (Leonardo) as an ISP and I could still run code on the Uno, but it still did not work with my other system at 375k baud).

This confused me, because I really thought that a 12MHz clock would work based on those calculations. At this point, I hooked up my oscilloscope and checked my baud rate this way. I determined that I was off dramatically (25% error) and that prompted this post.

@westfw, You are correct. I switched out the wrong oscillator. I removed the USB Chip Crystal and not the Main CPU resonator. I feel like the Uno itself is not well documented, because when I decided to try using a 12MHz clock over a 16MHz clock, I did research to verify that the larger oscillator on the Uno was correct and could find virtually no information about the layout of components on the Uno. So I (wrongly) assumed that I had found the correct oscillator and replaced it.

Going forward, where can I go to get this kind of information in documented format? I'm really grateful for all of your help, but I feel like it'd be a lot easier for everyone if I could just read about it before attempting (and spending money on) things that are destined to fail.

Thank you again to all!