Arduino Due baudrate higher than 115200

I am considering purchasing an Arduino Due board, but find some web pages stating that there is a bug in the ARM Cortex Processors, such that when setting baudrate higher than 115200 the communication between Arduino and the computer maybe broken. (http://www.copperhilltechnologies.com/arm-cortex-processors-uart-programming-problem-at-baud-rates-higher-than-115200/)

I wonder now in July 2018 is this bug fixed? Is current Arduino Due still affected? Since I may need a high baudrate I would like to know more about this bug before purchasing.

I am always using 250000 bauds with the serial monitor with no problem. FYI, the baud rate with the UART peripheral (Serial) is selected thru UART_BRGR register.

Baude Rate = MCK/(CD * 16), with 1< CD<65535. (Sam3x datsheet, page 768)

void setup() {

Serial.begin(250000);
Serial.println(UART->UART_BRGR);
/*  Output: 21 */
}

void loop() {
 
}

ard_newbie:
I am always using 250000 bauds with the serial monitor with no problem. FYI, the baud rate with the UART peripheral (Serial) is selected thru UART_BRGR register.

Baude Rate = MCK/(CD * 16), with 1< CD<65535. (Sam3x datsheet, page 768)

void setup() {

Serial.begin(250000);
Serial.println(UART->UART_BRGR);
/*  Output: 21 */
}

void loop() {

}

Hello, thanks for the reply! Can you please try the following code:

void setup() {
    Serial.begin(230400);
}

void loop() {
    delay(1000)
    Serial.print("Hello world!\n\r")
}

Open the serial monitor and see if it is displaying junk or text? Thank you very much!

http://www.copperhilltechnologies.com/arm-cortex-processors-uart-programming-problem-at-baud-rates-higher-than-115200/

From that page: " I believe the UART programming is somewhat universal between all ARM processor types. "

That statement is so completely wrong that I'm pretty sure it makes rest of the page untrustworthy.

Be aware, however, that the USB/Serial converter chip on the serial port ALSO has bitrate limitations. For the "programming port" of a genuine Arduino Due, the chip is an ATmega16u2, and it doesn't support 230400 very well. And... it looks like the Due UART initialization code doesn't "round", leading to errors similar to what the blog post might have been talking about. If those errors happen to go in opposite directions, "junk" is pretty likely.

You could try patching https://github.com/arduino/ArduinoCore-sam/blob/master/cores/arduino/UARTClass.cpp#L64 from

// Configure baudrate (asynchronous, no oversampling)
_pUart->UART_BRGR = (SystemCoreClock / dwBaudRate) >> 4;

To:

// Configure baudrate (asynchronous, no oversampling, with rounding)
_pUart->UART_BRGR = ((SystemCoreClock / dwBaudRate)+8) >> 4;

Display in Serial Monitor is all the more correct that CD is an integer for a given baud rate. With 230400, theorical CD should be 22.78, but in fact the integer used by UART will be 22 resulting in an x%error.

I did the test with Serial.begin(230400) and the output is correct if I select 250000 (and not 230400) in Serial Monitor, and garbage if I select 230400.

The error between the expected baud rate and the actual baud rate should be calculated this way:

Error % = (1 - (Expected baud rate/ actual baud rate)) * 100 %, and the error should be less than 5%.

With the above example:

Error % = (1 - (230400/238636)) * 100 % = 3.5 %

If for some weird reason you would need a fractionnal baud rate, you might consider using the USART peripheral rather than the UART peripheral. See Sam3x datasheet page 778.

I tried out my patch (which works), submitted an issue and a pull request: https://github.com/arduino/ArduinoCore-sam/issues/54

As a workaround, you should be able to do "Serial.begin(225000);", which will get you closer to the desired bit rate (about 1% off, and ... in the same direction as the 16u2 error!)