Max bytes in a single message through UART

t06afre

Joined May 11, 2009
5,934
It is 8 bits for 16c550 type UARTs. In many micro controllers parity is not supported by the hardware. But they accept 9 bit in each transmission. So this bit may be implemented for something else than parity. But I would not recommend this setup if one of the units communication is a general purpose UART (or unknown).
 

Papabravo

Joined Feb 24, 2006
21,159
In a typical UART there is no limit to the size of a message. It can be as many bytes as both sides are prepared to handle. For example RFC 1055 talks about SLIP (Serial Link Internet Protocol) aka TCP/IP over a serial port. Ethernet does have a maximum packet size in the neighborhood of 1520 bytes, but it is a synchronous protocol. A UART is asyncronous; that is a huge difference.
 

Papabravo

Joined Feb 24, 2006
21,159
If you are talking Microcontrollers, most have a 1 or 2 byte transmit and receive buffer....

B. Morse
I don't understand how you can posit an equivalence between a "message" and a "buffer". In no way that I know of are they even remotely the same thing. Even TCP/IP allows for the assembly of messages over multiple packets and buffers.
 

BMorse

Joined Sep 26, 2009
2,675
I don't understand how you can posit an equivalence between a "message" and a "buffer". In no way that I know of are they even remotely the same thing. Even TCP/IP allows for the assembly of messages over multiple packets and buffers.

In some cases, if sending multiple packets of data without any kind of handshaking going on, you could loose data if transmit buffer is full and you try to send more with out first waiting for buffer to be emptied or have some room for more data..... same with receiving, if data is not pulled quick enough from the buffer, you could loose some data also if other device keeps transmitting data....

here is an excerpt from the Pic16F887 datasheet:

The EUSART module includes the following capabilities:
• Full-duplex asynchronous transmit and receive
• Two-character input buffer
• One-character output buffer

• Programmable 8-bit or 9-bit character length
• Address detection in 9-bit mode
• Input buffer overrun error detection
• Received character framing error detection
• Half-duplex synchronous master
• Half-duplex synchronous slave
• Programmable clock polarity in synchronous
modes
• Sleep operation
The receive FIFO buffer can hold two characters. An
overrun error will be generated if a third character, in its
entirety, is received before RCREG is read to access
the FIFO. When this happens the OERR bit of the
RCSTA register is set. Previous data in the FIFO will
not be overwritten. The two characters in the FIFO
buffer can be read, however, no additional characters
will be received until the error is cleared. The OERR bit
can only be cleared by clearing the overrun condition.
If the overrun error occurred when the SREN bit is set
and CREN is clear then the error is cleared by reading
RCREG. If the overrun occurred when the CREN bit is
set then the error condition is cleared by either clearing
the CREN bit of the RCSTA register or by clearing the
SPEN bit which resets the EUSART.
this is what I meant in the first post.... Plus usually you would compose a "message" in a "buffer" before you can transmit it, so IMO they are directly related....

B. Morse
 
Last edited:

Papabravo

Joined Feb 24, 2006
21,159
You're entitled to your opinion about the relative meanings of "buffer" and "message", but I think the consensus of people I've worked with over the last 45 years is that a "buffer" has a fixed deterministic size and a message does not. One message may span multiple buffers as it does in TCP/IP or there may be "n" one character messages in a circular buffer of size "n". We are speaking here of memory buffers and not a handful of hardware registers that implement a FIFO of some depth in a UART.

In any case the OP's question had to do with the maximum size of a message, and there is no deterministic answer to that question because it depends on what the two processors that are talking want to define it as.
 

GetDeviceInfo

Joined Jun 7, 2009
2,192
further, a 'message' is something that is produced or consumed as a whole entity. If the transmitting or recieving device cannot accept or digest the transmission as a 'whole', then you've exceeded a useful length. This is different than data streaming, where some loss may acceptable.
 
Top