RS-232C Standard - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

RS-232C Standard

Description:

The RS-232C standard is an asynchronous serial communication method. Serial means that the information is sent 1-bit at a time. ... – PowerPoint PPT presentation

Number of Views:160
Avg rating:3.0/5.0
Slides: 20
Provided by: daniel351
Category:
Tags: 232c | danzig | standard

less

Transcript and Presenter's Notes

Title: RS-232C Standard


1
????? ????? ???????
  • ????? ?????? ??? ?????? ????? ???? ??????? ??
    ???? ?????? ????? ????? ????? ?????, ?????
    ???? ?????? ?????? ????? ?????

2
RS-232C Standard
  • The RS-232C standard is an asynchronous serial
    communication method.
  • Serial means that the information is sent 1-bit
    at a time.
  • Asynchronous means that the information isn't
    sent at predefined time slots (like with a fixed
    clock, for instance). See http//en.wikipedia.org/
    wiki/Asynchronous_serial_communication
  • The RS-232C standard works at the physical layer
    of the communication standard. This is the
    lowest level and the one that physically connects
    the devices.
  • The communication is done through the serial port
    of the PC. This is a male connector with 25 (old)
    or 9 (new) pins, in both cases only 9 pins, at
    the most, are used.

3
Why Use a Serial Interface?
  • Good question? We program in parallel (writing a
    value to a char, int, float), why communicate
    serially? Less data is transferred per send.
  • There are several reasons
  • Serial cables can be longer than parallel cables.
  • Serial cables are cheaper than parallel cables,
    although there is a cost of converting parallel
    data to the serial connection.
  • Infra Red are serial. Detecting 1 point of light
    isn't easy, try detecting 8 or more points of
    light.
  • Many microcontrollers (?????-??????) use SCI
    (Serial Communication Interface) to communicate
    with the outer world.
  • SATA disks are serial. See http//en.wikipedia.org
    /wiki/Serial_ATA

4
The Connector
  • The pins abbreviations are (numbers in
    parentheses are the 25D pin numbers.
  • 1. CD (8)
  • 2. RD (Rx) (3)
  • 3. TD (Tx) (2)
  • 4. DTR (20)
  • 5. SG (Ground) (7)
  • 6. DSR (6)
  • 7. RTS (4)
  • 8. CTS (5)
  • 9. RI (22)

5
9D to 25D Conversion
6
DTE and DCE
  • A DTE (Data Terminal Device) is usually a
    computer.
  • A DCE (Data Communication Device) is usually a
    Modem. A Cable connecting 2 PCs is also a Modem.
    It is called a NULL Modem.
  • The problem with communications is that the DTE
    speed is much greater than the DCE speed. The
    communication protocol bridges this gap (???? ??
    ????).
  • The DCE to DCE speed is also called the line
    speed.
  • Maximum Modem speed today is 56K BPS (56K Bits
    Per Second), this is the line speed. On the other
    hand the maximum DTE/DCE speed is 115,200 BPS.
    This is the gap software must bridge.

7
The UART 8250
  • OK, lets say we understood the previous slides.
    How does the CPU send signals through the serial
    port?
  • A UART (Universal Asynchronous Receiver/Transmitte
    r) is used. The UART is a device that the CPU
    programs to perform tasks for it.
  • In our case the UART 8250 is the device that
    controls the serial port. The 8250 is the first
    of a family that contains the 8250B, 16450, 16550
    and others.
  • The 8250 was introduced with the XT PC, so your
    computer probably has a later version. But all
    are backward compatible, so we can program as
    though we have a 8250.

8
Programming the UART 8250
  • Programming is done by reading and writing
    registers of the 8250. The registers are
  • Base Address Mode Name

  • 0 (DLAB0) Write Transmitter Holding Buffer
    THR
  • 0 (DLAB0) Read Receiver Buffer RBR
  • 0 (DLAB1) Rd/Wr Divisor Latch Low Byte DLL
  • 1 (DLAB0) Rd/Wr Interrupt Enable Register
    IER
  • 1 (DLAB1) Rd/Wr Divisor Latch High Byte DLM
  • 2 Read Interrupt Idendification Register IIR
  • 2 Write FIFO Control Register FCR
  • 3 Rd/Wr Line Control Register LCR
  • 4 Rd/Wr Modem Control Register MCR
  • 5 Read Line Status Register LSR
  • 6 Read Modem Status Register MSR
  • 7 Rd/Wr Scratch Register SCR

9
Accessing the Registers
  • On the 80x86 architecture I/O devices are
    accessed using special I/O instructions. These
    instructions are called IN and OUT, access I/O
    Ports.
  • I/O Ports are addresses in what's called I/O
    space, these are addresses that when accessed
    using the special I/O instructions access the
    registers of I/O devices.
  • The PC has standard ports for the serial
    interfaces, these ports are called COM1 - COM4.
    They are mapped to the following port numbers and
    IRQ (Interrupt Request) lines.
  • Name Port address IRQ
  • COM 1 3F8 4
  • COM 2 2F8 3 (usually the serial mouse)
  • COM 3 3E8 4
  • COM 4 2F8 3

10
Getting the Port Addresses
  • include ltstdio.hgt
  • include ltdos.hgt
  • void main(void)
  • unsigned int far ptraddr / Pointer to
    location of Port Addresses /
  • unsigned int address,a / Address of Port /
  • ptraddr(unsigned int far )0x00000400
  • for (a 0 a lt 4 a)
  • address ptraddr
  • if (address 0)
  • printf("No port found for COMd \n",a1)
  • else
  • printf("Address assigned to COMd is
    Xh\n",a1,address) ptraddr

11
Accessing the Registers
  • The port addresses for the COMs are defined in
    the BIOS (Basic I/O System) ROM (Read Only
    Memory) from addresses 0x400 to 0x408.
  • OK. So how do we access the registers?
  • There is a C interface to the IN and OUT
    instructionsint inp(unsigned short port)
    // read a byte from the portint
    outp(unsigned short port, int val)
    // write a byte to the port
  • Using these two instruction is is possible to
    access the registers defined in the previous
    slides. For instance to read the LCR we have to
    writeint valval inp(0x3F8 3) // or
    inp(0x3FB)
  • Look at the functions descriptions in the help
    manuals of Visual C or BorlandC.

12
Real vs. Protected Mode
  • Protected mode is the mode that the computer runs
    in when it has to support multiple users. UNIX
    and XP run only in protected mode. A regular user
    can
Write a Comment
User Comments (0)
About PowerShow.com