Sunday, March 24, 2013

RS232, serial port, UART

RS232, serial port, UART

The RS232 DB9 connector is one of legacy communication interface that today still using it. The RS232 is traditional name for serial communication. This interface protocol is very simple, easy to understand and design. This interface last time using in telecommunications, it function seem like replaced by Messager today. This interface is using ASCII symbol to communicate, therefore, you can sending any text file throw this interface. Hyper-terminal is software that used to manage this interface. It can configure the interface, sending key, sending file or as received.

Today, there a lot of communication between IC to IC still using this interface, but, they called the interface as Universal Asynchronous receiver or transmitter (UART). UART still follow the RS232 standard, but it reduce the number signal pin. UART is 3-wire RS232 system, which consisting TxD, RxD and GND. When hardware required in 2 way, the RTS and CTS line are added in, become 5-wire RS232 system.

The standard RS232 signal level is in between +15V to -15V.  Voltage range between -3 to +3 volts is not a valid RS-232 level. High in range +15 ~ +5V and Low in range -15 ~ -5V. The UART signal level is TTL signal level. High will be +5V and Low will be 0V.

This interface still very useful, for embedded project can use this interface to communicate with PC.

DB9 Female and Male pin number

Pin out and signal name


Pin Number Signal Signal Name
1 DCD Carrier Detect
2 RxD Received Data
3 TxD Transmitted Data
4 DTR Data Terminal Ready
5 GND Common Ground
Signal Ground
6 DSR Data Set Ready
7 RTS Request To Send
8 CTS Clear To Send
9 RI Ring Indicator

Serial Communication Parameter

Bit per Second also named as baud rate. Number of bit per second, it will determine the signal width.
Example:-
Baud rate = 9600
Data width = 1/9600 = 104.167us

Data bits is data frame size. (number bits of data)

Parity is check bit use for error detecting. The parity is last bit of data (before stop bit).
None = All data bit is data.
Even  = 1 = when high (1) bits count is odd.
         = 0 = when high (1) bits count is even.

Odd  = 1 = when high (1) bits count is even.
         = 0 = when high (1) bits count is odd.

Mark = parity bit always 1.
Space = parity bit always 0.

Example for Even and Odd:-
7 bits of data High (1) bit count 8 bits including parity
Even Odd
0000000
0
00000000 00000001
0011000
2
00110000 00110001
1001010
3
10010101 10010100

Stop bits is configure the stop bit length.

Flow control is configure the communication handshaking method. It can control by hardware or software or none.

Communication Signal frame

The figure shown the 8 bit RS232 and UART signal (TTL signal). This communication use one signal format only for Transmit and Receive.
The IC (micro-controller) something will offer 8-bits UART or 9-bit UART. The difference between is data size, the 9-bit UART will have 9 bit of data. The start and stop bit still remain.

No comments:

Post a Comment