RS232 Protocol
RS232 Protocol
RS232 Protocol
It is the primary protocol used over modem lines.Figu re shows the relationship between the various components in a serial ink. These components are the UART, the serial channel, and the interface logic. An interf ace chip known as the universal asynchronous receiver/transmitter or UART is use d to implement serial data transmission. The UART sits between the host computer and the serial channel. Figure: Asynchronous (RS-232) serial link A frame is a complete and nondivisible packet of bits. A frame includes both inf ormation (e.g., data and characters) and overhead (e.g., start bit, error checki ng and stop bits). In asynchronous serial protocols such as RS-232, the frame co nsists of one start bit, seven or eight data bits, parity bits, and stop bits. A timing diagram for an RS-232 frame consisting of one start bit, 7 data bits, on e parity bits and two stop bits is shown below in figure Figure : RS-232 Frame (1 start bit, 7 data bits, 1 parity bits, and 2 stop bits) The start bit is used to signal the beginning of a frame and the stop bit is use d to signal the end of a frame. Parity is used to detect transmission errors. Fo r even parity checking, the number of 1's in the data plus the parity bit must e qual an even number. For odd parity, this sum must be an odd number. Parity bits are used to detect errors in transmitted data. Before sending out a frame, the transmitter sets the parity bit so that the frame has either even or odd parity. The receiver and transmitter have already agreed upon which type of parity chec k (even or odd) is being used. When the frame is received, then the receiver che cks the parity of the received frame. If the parity is wrong, then the receiver knows an error occurred in transmission and the receiver can request that the tr ansmitter re-send the frame. RS232 physical properties: The RS232 standard describes a communication method capable of communicating in different environments. This has had its impact on the maximum allowable voltage s etc. on the pins. The maximum baud rate defined for example is 20 kbps. With c urrent devices like the 16550A UART, maximum speeds of 1.5 Mbps are allowed. Voltages: The signal level of the RS232 pins can have two states. A high bit, or mark stat e is identified by a negative voltage and a low bit or space state uses a positi ve value. This might be a bit confusing, because in normal circumstances, high l ogical values are defined by high voltages also. The voltage limits are shown be low. Level Transmitter capable (V) Receiver capable (V) Space state (0) +5 ... +15 +3 ... +25 Mark state (1) -5 ... -15 -3 ... -25 Undefined -3 ... +3 Figure: RS232 voltage values NOTE: Despite the high voltages present, it is not possible to destroy the serial port by short circuiting. Only applying external voltages with high currents may eve ntually burn out the driver chips. Still then, the UART won't be damaged in most cases. Maximum cable length: The standard has a clear answer, the maximum cable length is 50 feet, or the cab le length equal to a capacitance of 2500 pF. The latter rule is often forgotten. This means that using a cable with low capacitance allows you to span longer di stances without going beyond the limitations of the standard. Error detection:
It is the frame detection mechanism which is used to test if the incomming bits were properly surrounded by a start and stop bit pair. For further error checkin g, a parity bit can be used. The use of this bit is however not mandatory. If th e existence of wrong bits is rare (when communicating with an internal modem for example) or if a higher level protocol is used for error detection and correcti on (Z-modem, RAS, etc) communication speed can be increased by not using the par ity feature present on the UART. Parity is a simple way to encode a data word to have a mechanism to detect an er ror in the information. The method used with serial communications adds one bit to each data word. The value of this bit depends on the value of the data word. It is necessary that both the transmitter and receiver use the same algorithm to calculate the value of the parity bit. Otherwise, the receiver may detect error s which are not present.