Mega 2560 <-> 16U2 Baudrate & Double Buffering of Serial Data

FIRST QUESTION
I have searched and dont believe this question has been asked before. What I am seeking to understand is how the baudrate between the TTL-232 pins (D0 & D1) on Mega to the 16U2 (also applies to the Uno board) determines the baud rate.

The operation of the TTL-232 between the 2560 and 16U2 requires that both ends know the baud rate to operate correctly unless synchronous serial is used (which I understand it is not).

This means that when one puts code such as:

Serial.begin (115200);

into an Arduino .ino script file there logically must be a way of communicating this to the 16U2 which has to receive it and put it onto the USB port. I have reached that conclusion that I believe the baud rate asked, in the case of the Mega and Uno, is actually irrelevant to the 2560 <-> 16U2 comms. I suspect that it goes at 115200 irrespective of what is specified as I believe this is around the fastest reliable speed attainable.

Is this correct or am I missing something ?

SECOND QUESTION
Given that the serial data is sent to the 16U2 immediately the reality for the UNO & Mega is that the serial buffer specified in Arduino at around 64 bytes (from memory) is actually one of two buffers with the second one being in the 16U2.

My question is does this mean that the size of the Arduino serial buffer for UNO & Mega is largely irrelevant because of this double buffering ?

Geoffrey Brown, NZ

The baud rate specified in Serial.begin() is relevant for the UART communication between the ATmega2560 and the 16U2. While the USB communication isn't affected by the baud rate, the two microcontrollers need to be synchronized.

The ATmega2560's serial buffer is still important, even though the 16U2 has its own buffers. Double buffering doesn't make the 2560's buffer irrelevant; it still plays a role in managing the flow of data between the 2560 and 16U2.

1 Like

The baudrate of the 16U2 is configured by USB. E.g. if you open the serial monitor, you must set the baudrate in the monitor accordingly. This is transfered to the 16U2 so that it can set the correct baudrate at its UART to the 2560. The same is true if you use another (terminal) program at your PC.

Ah yes - had forgotten about the possibility of the serial baud rate being communicated from the PC connected to USB then to the 16U2. Many thanks for that.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.