ICT3107-Microprocessor and Interfacing
Lecture Notes # 19
Outline of the Lecture
• Interfacing the Serial Port
• Basics of Serial Communication
• Asynchronous Data Communication and Data Framing
• RS232 and other Serial I/O Standards
BASICS OF SERIAL COMMUNICATION
   ¾ Computers transfer data in two ways: parallel and serial.
     Compare and contrast between serial and parallel transmission.
       •   Parallel communication is fast and efficient. In parallel communication 8 or more
           lines (wire conductors) are used to transfer data to a device that only a few feet
           away. (e.g. printers, hard disks etc.)
       •   Parallel communication provides much faster transfer of data with compared to
           serial communication.
       •   However for long distances the number of wires required as well as the
           distortion on the signals in parallel wires makes parallel communication for long
           distances not reliable. Also the synchronization of the parallel signals is a big
           problem.
       •   Serial communication sends 1 bit at a time, so it is slower with compared to
           parallel communication.
       •   For long distances serial communication provides robust way of data transfer.
           Because there is no problem of synchronization.
       •   Serial communication requires less number of wires for communication. Serial
           communication is used in modems, keyboards etc.
       Serial Data Transfer                                           Parallel Transfer
                                                                        D0
       Sender                 Receiver
                                                            Sender                  Receiver
                                                                         D7
Serial versus Parallel Data transfer.
Asynchronous /Synchronous Methods
¾ Serial data communication uses two methods: asynchronous and synchronous.
     • Synchronous communication requires common timing signals and common
         clock for synchronization. This means that as well as the data, the clock signals
         must also be transmitted along. In synchronous method a block of data at a time
         is transmitted. 1ta line data hoile arekta line clk emne pathaite hbe.
       •   In asynchronous method a single byte is transferred at a time. For example,
           start and stop bits are used to indicate the receipt of a byte.
                                                                                            1
Serial Data Communication Systems
       •   Simplex Transmission: Transmission of data is only possible in one direction
           (e.g. output only-printers)
       •   Half Duplex Transmission: Transmission of data is possible in both directions,
           but in one direction at a time.
       •   Full Duplex Transmission: Transmission of data can be in both directions at a
           time. Requires to wires as data lines. 2ta link or 2ta connection line lagbe
                                                   2ta channel
                                                   2ta wire
                                                   example: mobile
                  Transmitter                                                  Receiver
    Simplex
                  Transmitter                                                   Receiver
    Half Duplex
                  Receiver                                                      Transmitter
                  Transmitter                                                   Receiver
   Full Duplex
                  Receiver                                                     Transmitter
   Simplex, Half and Full Duplex Transfers
UART (Universal Asynchronous Receiver-Transmitter) Chip
UART chips are used for serial communication. The 8250 series, which includes the
16450, 16550, 16650, & 16750 UARTS, are the most commonly used.
• Asynchronous serial communication and data framing
 ¾ The data coming in the receiving end of the data line in a serial data transfer is all 1s
  and 0s; it is difficult to make sense of data unless the sender and receiver agree on a
  set of rules, a protocol on how the data is packed, how many bits constitute a
  character, and when the data begins and ends.
 Start and Stop bits
 ¾ Asynchronous serial data communication is widely used for character-oriented
  transmission, and block-oriented data transfers use the Synchronous method.
                                                                                               2
   ¾ In the Asynchronous method, each character is put between a start and stop bits. This
    is called framing. In data framing, for asynchronous communications, the data such as
    ASCII characters are packed in between a start bit and stop bit.
   ¾ The start bit is always one bit, but the stop bit(s) can be one or two bits. The start bit
    is always a 0 (low) and the stop bit(s) is 1 (high)
   ¾ The example below gives the framing of the ASCII character “A”, where, binary
    0100 0001, is framed in between the start bit and two stop bits. Notice that the LSB is
    sent out first.
      start bit - 1bit (0)
      stop bit-1 or 2 bit depending on protocol (1)
                                       4                                1
  Framing of ASCII “A” (41H)
     ¾ Notice that the transmission begins with a start bit followed by D0, the LSB, then the
       rest of the bits until the MSB (D7), and finally, the 2 stop bits indicating the end of
       character “A”.
     ¾ In asynchronous serial communication, peripheral chips and modems can be
       programmed for data that is 5, 6, 7 or 8 bits wide.
                                                jtai pathano hy otai jno receive kore
     ¾ In some systems in order to maintain the data integrity, the parity bit of the
       character byte is included in the data frame.      actual data baade baki gulo overhead. link
                                                                    establish korte eta pathatei hbe. total frame e
                                                                    actual data charao start bit , stop bit, parity milay
  Data Transfer Rate (Baud Rate)                                    12 bit but 8 bit hoilo actual data bit. one third of ur
                                                                    total capacity. Total jei capacity
     ¾ The rate of data transfer in serial communication is stated in bps (bits per second).
       Another widely used terminology for bps is the baud rate.
     ¾ Typical bps values are: 2,400, 4,800, 9,600, 19,200, 28,800,… etc.
dial up modem dye ISP der call dte hoto aagekar amole.
  • RS232 and other Serial I/O Standards
      ¾ RS232 is the most widely used serial I/O interfacing standard.
                                                      transistor transistor logic
      ¾ However the I/O voltage levels are not TTL compatible. In the RS232 a 1 is
        represented by –3 to –25 V, while 0 bit is +3 to +25 V, making –3 to +3 undefined.
      ¾ For this reason voltage converter such as MC1488 and MC1489 are used to
        convert the TTL logic levels to the RS232 voltage levels and vice versa. See Figure
        below.
                                                                                                         3
RS232 Pins
   ¾ Serial Ports come in two "sizes". There are the D-Type 25 pin connector and the D-
     Type 9 pin connector both of which are male on the back of the PC, thus you will
     require a female connector on your device. Below is a table of pin connections for
     the 9 pin and 25 pin D-Type connectors.
   D-Type 25 pin                             D-Type 9-pin
  only 9ta pin e kaj kore.
Serial Port Pinouts (D25 and D9 Connectors) kaj gulo only mn e rakhbo
           D-Type-25 Pin        D-Type-9 Pin
                                                   Abbreviation          Full Name
                No.                 No.
                 Pin 2               Pin 3           TD / TxD          Transmit Data      basic 2ta pin for serial
                 Pin 3               Pin 2          RD / (RxD)          Receive Data      communication
                 Pin 4               Pin 7              RTS          Request To Send
                 Pin 5               Pin 8              CTS            Clear To Send
                 Pin 6               Pin 6              DSR           Data Set Ready
                 Pin 7               Pin 5          SG / (GND)         Signal Ground
                 Pin 8               Pin 1          CD / (DCD)      Data Carrier Detect
                                                                       Data Terminal
                Pin 20               Pin 4              DTR
                                                                          Ready
                Pin 22               Pin 9               RI            Ring Indicator
                             Table 1 : D Type 9 Pin and D Type 25 Pin Connectors
                                                                                                4
                                                               Data exchange er aage basically they need to setup the link..link k aage establish korte hbe
                                Pin Functions                  Link establish kore holo DSR, DTR ei 2ta pin dye.
                                                               Aage 2pokkho thke link establish korbe then 2 pokkho blbe j ami data exchange korte raji
                                                               Then finally RD r TD dye receive r transmit hbe data
                                  Abbreviation Full Name         Function
                                    TD         Transmit
                                                                 Serial Data Output (TXD)
                                               Data                                     TDTD  transmit
                                                                                           transmit    data,
                                                                                                    data,    serial
                                                                                                          serial    data
                                                                                                                 data  out
                                    RD         Receive Data                               out
                                                                 Serial Data Input (RXD)RD hlo rcv data, serial data IN
                                                                                          RD hlo rcv data, serialdataIN
    data                            CTS        Clear to Send     This line indicates that the Modem is ready to
    pathanor                                                     exchange data.                                            onno end er modem ready
    aage DSR,                        DCD        Data Carrier     When the modem detects a "Carrier" from thehoile          modem
                                                                                                                                ei pin ta k set korbe
    DTR link                                    Detect           modem at the other end of the phone line, this Line
    establish kore                                               becomes active. modem lineup check kore j, kono ekta numbr theke ring
                                                                                    hoille she connection establish korte chacche eta bujhe
                                     DSR        Data Set         This tells the UART that the modem is ready to
                                                Ready            establish a link.
                                     DTR        Data
                                                                 This is the opposite to DSR. This tells the Modem
                                                Terminal
                                                                 that the UART is ready to link.
RTS Pin ta 1st e request korbe,
                                                Ready
UART RTS pin k actv kore             RTS        Request To       This line informs the Modem that the UART is ready
modem k blbe ami data xchng
korte ready                                     Send             to exchange data.
RTS pin actv hoile modem
                                     RI         Ring Indicator   Goes active when modem detects a ringing signal.
abar blbe ami xchng korte
ready..kivabe? CTS pin k actv
kore
                    Data Communication Classification:                   modem just convey kore=>DCE
                  ¾ Devices which use serial cables for their communication are split into two
                    categories. These are DCE (Data Communications Equipment) and DTE (Data
    data consumer   Terminal Equipment.)
                  ¾ DTE refers to terminals and computers that send and receive data; DCE refers to
                    communication equipment such as modems that are responsible for transferring
                    data.
                         8255 er control register k program kore serial port configure kora=> next lecture