EmbLogic's Blog

Serial Port Communication

Serial Port Communication


Serial communication is the process of sending data one bit at a time, sequentially, over a communication channel or computer bus where as in case of parallel communication, where several bits are sent as a whole, on a link with several parallel channels. Serial communication is used for all long distance communication and most computer networks, where the difficulties like cost and synchronization make parallel communication difficult. Serial communication mostly refers to the RS-232 communication protocol where 9 pin connectors used for communication between 2 devices.

RS-232 Protocol:

RS-232 is the name for a standards for serial binary single-ended data and control signals connecting between data terminal equipment and data circuit-terminating equipment. It is commonly used in computer serial ports. The standard defines the electrical characteristics and signals timing, size and pin-out of connectors. This protocol defines the maximum open-circuit voltage of +/- 25 volts. Valid signals are in the range of +3 to +15 volts or the range ?3 to ?15 volts with respect to the ground. The range between ?3 to +3 volts is not a valid RS-232 level. For data transmission lines (TxD, RxD etc.) logic one is defined as a negative voltage and the condition is called mark. Logic zero is +ve and the signal condition is termed space. Control signals have the opposite polarity: the active state is positive voltage and the inactive state is negative voltage.

The following is commonly used RS-232 signals and pin:

  • Pin 1 = CT (Carrier Detect)

  • Pin 2 = RxD (Received Data)

  • Pin 3 = TxD (Transmitted Data)

  • Pin 4 = DTR (Data Terminal Ready)

  • Pin 5 = Ground

  • Pin 6 = DSR (Data Set Ready)

  • Pin 7 = RTS (Request To Send)

  • Pin 8 = CTS (Clear To Send)

  • Pin 9 = RI (Ring Indicator)

Serial Port base Address and IRQ Number:

Serial Port has following base addresses and IRQ number associated with it:

      1. 3F8 4

      2. 2F8 3

      3. 3E8 4

      4. 2E8 3

The most commonly used UART IC in personal computers is pc16550D. It has 8 registers which are used for controlling the data transmission. They are:

Register 0: Receiver Buffer Register(Read Only) & Transmitter Register(Write Only).

These buffer are used for receiving and transmitting data between two devices.

Register 1: Interrupt Enable register

This register is used to enabling the interrupts. Setting bit 0-3 will enable Receive Data Available, Transmitter empty, Line Status Interrupt and Modem Status Interrupt.

Register 2 : Interrupts Identification Register(R/O) & FIFO Control Register (W/O)

IIR : If any interrupt has occurred, reading out this register will give the corresponding interrupt value.

FCR : This will enable the FIFO mode for UART i.e. it will store up-to 14 bytes of data before transmission.

Register 3 : Line Control Register :

This register controls the transmission pattern of data. It is also used to set the baud rate of the UART by setting bit 7 and writing value in Divisor latch buffers.

Register 4 : Modem Control Register:

Used to start the handshaking mechanism between host and peripheral.

Register 5: Line status Register :

This register is used to get the line status and if data is available. It is a read only register.

Register 6: Modem Status Register:

This register shows the current state of data line when read.

Register 7: Scratch Register

Divisor Latch (LS) & (MS) :

These register together forms a 16bit register when the bit7 of LCR register is set. They hold the multiplier value, to set the baud rate of the UART at desired rate.

Data Transmission:

First the transmitter will indicate the receiver by setting is MCR bit0 which will notify the receiver at MSR bit5 as pin 4 of transmitter is connected to pin 6 of receiver. After receiving the signal DSR, receiver will set its MCR bit1 which is connected to transmitter’s RTS pin and will notify the transmitter that he is ready to receive data. Then transmitter will put the data in Transmitter buffer and receiver will receive the data in receiver buffer.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>