Serial Port Programming Part 7 - Should we connect TX-TX or TX-RX

RS232 is an serial communication standard developed by Electronics Industries Association (EIA) in 1960. It has several revisions through the years with an alphabet at the end to denote the revision number such as RS232C.

RS in RS232 stands for Recommended Standard. Standard defines the maximum length of the cable as 15 meters. But the revised standards specify the maximum length in terms of capacitance per unit length.

RS232 standard defines two types of devices:

1. DTE (Data Terminal Equipment) : Refers to terminals and computers that send and receive data
E.g. Serial Port on PC

2. DCE (Data Communication Equipment): Refers to communication equipment, such as modems that is responsible for transferring the data.
E.g. Modem

For short distance communication, digital signal can be transferred on a simple wire. During long-distance communication we need modem. Modem will convert 0s and 1s to audio tones (modulate) before sending the data on the transmission media and then convert the audio tones to 0s and 1s (demodulate) at the receiving end.

 RS233 standard specifies a 25-pin Type -D connector to support the full functionality of RS232. DTE device uses the female outer casing with male pins and DCE device uses the male outer casing with female pins

As applications do not use all the 25 pins and electronic equipment are getting smaller, reduced 9-pin connector is used commonly called as DE-9 (wrongly called DB-9).

Minimum pins required for connecting two serial devices:
1. TD (Transmit Data)
2. RD (Receive Data)
3. GND

When connecting a DTE (PC) to DCE(Modem) need to connect the following

TD(DTE) - TD(DCE)
RD(DTE) - RD(DCE)
GND(DTE) - GND(DCE)

This type of cabling is called "Straight through" cable.


When connecting a DTE to DTE device, following connections are needed

TD(DTE1) - RD(DTE2)
RD(DTE1) - TD(DTE2)
GND(DTE1) - GND(DTE2)

This type of cabling is called "Null Modem" cable.


How to determine whether a device is DTE or DCE?

To determine whether the device is DTE or DCE check the voltage on pins 2 and 3. The transmitter will always have a negative voltage even in idle condition. 
  • If the pin2 is negative, the device is DTE
  • If the pin3 is negative, the device is DCE


Comments

Popular posts from this blog

bb.utils.contains yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto