Serial Port Complete - Latest Microcontroller projects

(lily) #1
Formats and Protocols

flow_control_out to eliminate confusion about which signal is the input and
which is the output.
Two additional RS-232 flow-control signals are Data Terminal Ready (DTR)
and Data Set Ready (DSR). These lines were defined as a means for providing
information about the status of a phone line or other communication channel
on a modem that connects via RS-232 to a computer or terminal. On PCs,
DTR is an output and DSR is an input. Microcontrollers typically don’t have
dedicated DTR and DSR lines. Spare port pins with firmware support can pro-
vide these signals when needed. Chapter 5 has more about RS-232 signals.
Some links can use software flow control, where a receiving computer sends an
Xon code to indicate that the computer is ready to receive and sends an Xoff
code to tell the transmitter to stop sending. This method works only when
sending data such as plain English text or another encoding that doesn’t use the
Xon and Xoff codes in other data. The Xon code point is typically 11h (Con-
trol+Q), and Xoff is 13h (Control+S). Some software drivers enable selecting
different codes.
A link can use hardware and software flow-control methods at the same time.
The transmitting computer sends data only if the remote computer’s CTS line
is high and the transmitting computer hasn’t received an Xoff.

6
33


Hardware and software buffers can help to prevent missed data and enable data
to transfer as quickly as possible. The buffers can store received data and data
waiting to be sent. On a port without flow control, a receive buffer can prevent
missed data by storing received data until program code can retrieve the data.
On a port with flow control and a receive buffer, the transmitting computer can
send large quantities of data even if the receiving computer can’t process the
data right away. Transmit buffers can enable software to store data to be sent
and move on to other tasks.
The buffers can be in hardware, software, or both. Serial ports on PCs typically
have 16-byte hardware buffers built into the UARTs. In the receive direction,
the UART can store up to 16 bytes before software needs to read them. In the
transmit direction, the UART can store up to 16 bytes and transmits the bytes
using the selected protocol. Some UARTs, including those in many Virtual
COM-port devices, have larger hardware buffers.
Free download pdf