program point of view understanding of RS232 protocol

 rs232_level_conv

RS-232 protocol is introduced by EIA (Electronics Industries Association) in 1969 for serial communication. Protocol is nothing but just simple set of rules decided to use while communicating.

RS232-DB9-02

    • DTE and DCE 

 

DTE stands for Data Terminal Equipment. A computer is a DTE. DCE stands for Data Communication Equipment. A modems, microcontrollers,etc are a DCE. DTE normally comes with a Male Connector, while DCE comes with a Female Connector. However, that is not always true. Use the simple way below to confirm: Measure Pin 3 and Pin 5 of a DB-9 Connector with a Volt Meter, if you get a voltage of -3V to -15V, then it is a DTE device. If the voltage is on Pin 2, then it is a DCE device.

 

Note: The result for a DB-25 Connector is reversed (Please refer to DB-9 to DB-25 conversion table below).

  • RS-232 Pin outs (DB-9)

RS232-PinsA male DB-9 connector viewed from the front. Reverse or back view of male connector for Female Connector.

 

DTE Pin Assignment (DB-9)

DCE Pin Assignment (DB-9)

1

DCD

Data Carrier Detect

1

DCD

Data Carrier Detect

2

RxD

Receive Data

2

TxD

Transmit Data

3

TxD

Transmit Data

3

RxD

Receive Data

4

DTR

Data Terminal Ready

4

DSR

Data Set Ready

5

GND

Ground (Signal)

5

GND

Ground (Signal)

6

DSR

Data Set Ready

6

DTR

Data Terminal Ready

7

RTS

Request to Send

7

CTS

Clear to Send

8

CTS

Clear to Send

8

RTS

Request to Send

9

RI

Ring Indicator

9

RI

Ring Indicator

 

DB-9 to DB-25 Conversion

DB-9

DB-25

Function

1

8

DCD

Data Carrier Detect

2

3

RxD

Receive Data

3

2

TxD

Transmit Data

4

20

DTR

Data Terminal Ready

5

7

GND

Ground (Signal)

6

6

DSR

Data Set Ready

7

4

RTS

Request to Send

8

5

CTS

Clear to Send

9

22

RI

Ring Indicator

 

  • RS-232 Data format 

 

Data format: 1 Start bit, 8 Data bits, No Parity, 1 Stop bit. The data transmission starts with a Start bit, followed by the data bits (LSB sent first and MSB sent last), and ends with a “Stop” bit.

The voltage of Logic “1” (Mark) is between -3VDC to -15VDC, while the Logic “0” (Space) is between +3VDC to +15VDC.

  • Setting the baud rate

 

  • Baud rate is generally measured in bit per second and this is used in modem terminology. Baud rate is nothing but signal state change per second.
  • For faithfull communication between computer and microcontroller, we need to synchronize the baud rate of both devices.
  • For round figure baud rate and neat communication we have choose frequency of oscillator 11.0592 MHz exactly.
  • Below figure show how this frequency is divided and use by different part of system and at the end we get desired baud rate.
  • serial communication is always done in Timer 1 mode 2 when divided by Timer circuit.

 Untitled

  • Same as if we use TH=-6, Baud rate is equal to 4800 bps and so on.
  • This is all about RS-232 protocol. Next tab circuit diagram shows how to connect your personal computer with microcontroller with line driver IC.