63
Interface Design Serial Communications

08-Serial Main Ppt

Embed Size (px)

Citation preview

Page 1: 08-Serial Main Ppt

Interface DesignSerial Communications

Page 2: 08-Serial Main Ppt

• Draw the internal block diagram of 8251 and explain about each block • Distinguish between Synchronous and Asynchronous data formats. • Give the specifications of RS232C?• Explain about line driver and line receiver used in serial communication?• Give the status register of 8251 and explain each bit. • What are the important features of 8251?• Explain the following control words of 8251. With suitable Examples.• i. Mode word ii Command word• Discuss the types of serial communication?Write ALP for receiving 50 characters using 8251 and store them in memory at location

2080H.• Describe the Asynchronous transmission and reception schemes in detail. Draw the flowchart how sync serial data can be sent from a port line using software

routine.• Explain the operation of 8251 in Asynchronous mode of communication.• How TTL to RS-232C and RS-232C to TTL conversions are achieved? • Explain the line driver and the line receiver circuits of serial communication.What do you mean by I/O mapped I/O? Draw interfacing of 8251 with 8086 in I/O

mapped I/O Draw circuit to interface 8251 to an 8086 with address 0A0H. Write ALP to initialize

8251 for sync transmission with odd parity, single SYNC character, 8-bit data char

Page 3: 08-Serial Main Ppt

• (a) What is the difference between 20mA current loop and RS232−C standard?• 8. Interface 8251 with 8086 at address 40H. Initialize it in asynchronous transmit

mode, with 7 bit character size, baud rate factor 16, one start bit, one stop bit, even parity enable. Further transmit a message “BEST of” in ASCII from to a modem?

Terminal transmits asynchronous serial data at 1200 bd. What is the bit time? Assume 8 data bits, a parity bit and 1 stop bit how long does it take to transmit one char?

• Draw circuit to interface 8251 to an 8086 based system with an address 0C0H. Write the sequence of instructions to initialize 8251 for synchronous transmission?

• (b) How do we connect RS-232C equipment• i. To data terminal type devices? ii. To serial port of SDK ?86, RS-232C connection? Discuss the mode instruction format of 8251 for sync and async mode of operation? Describe the functions of DSR, DTR, RTS, CTS, TXD, and RXD signals exchanged

between a terminal and a modem.Why is sync serial data communication much more efficient than async comm?ALP to initialize 8251 in sync mode with even parity, single SYNCH character, 7 bit data

character. Then receive FFH bytes of data from a remote terminal and store it in the memory at address 5000 H: 2000H.

Explain the Handshaking signal sequence for a system using modem.

Page 4: 08-Serial Main Ppt

What is Serial Communications

Page 5: 08-Serial Main Ppt

Serial Communication Types

• Asynchronous

• Synchronous

• Transfer:

– Simplex

– Half duplex

– Full duplex

Page 6: 08-Serial Main Ppt

Transfer Types

Page 7: 08-Serial Main Ppt

BAUD Rate

• Data transmission rates are also specified in terms of baud rates.

• A baud is a unit of signaling speed that is equal to the number of discrete events occurring per second.

• The key idea here is that an event contains more than one bit of information.

• Therefore, the baud rate can be less than the bit rate.

• With only two levels of logic the baud rate equals the bit rate.

• However, inside a modem, the logic levels are converted to tones.

Page 8: 08-Serial Main Ppt

• A typical implementation is the transmit sine waves with different phases, – e.g., sin(bt + 0o), sin(bt + 90o), sin(bt + 180o), and sin(bt + 270o).

• The transmission can switch to any phase and since there are four possible phases, it takes two bits to code this information, i.e. 0o = 00, 90o = 01, etc.

• Detecting the phase at a particular time produces 2 bits of information.

– Therefore, the bit rate is twice as fast as the baud rate in this case.

• A 9600 bps modem typically has a baud rate of 2400 baud.

• Transmission rates are sometimes referred to in units of

characters/second.

Page 9: 08-Serial Main Ppt

Asynchronous• Asynchronous means "no synchronization", and thus does not

require sending and receiving idle characters. However, the beginning and end of each byte of data must be identified by start and stop bits. The start bit indicate when the data byte is about to begin and the stop bit signals when it ends. The requirement to send these additional two bits cause asynchronous communications to be slightly slower than synchronous however it has the advantage that the processor does not have to deal with the additional idle characters.

An asynchronous line that is idle is identified with a value of 1, (also called a mark state). By using this value to indicate that no data is currently being sent, the devices are able to distinguish between an idle state and a disconnected line. When a character is about to be transmitted, a start bit is sent. A start bit has a value of 0, (also called a space state). Thus, when the line switches from a value of 1 to a value of 0, the receiver is alerted that a data character is about to come down the line.

Page 10: 08-Serial Main Ppt

Asynchronous• Asynchronous communication transmits one character at a

time by adding start and stop bits to the character code.

• The asynchronously transmitted character is composed of

• 5 to 8 data bits,

•an optional parity bit, and

•either 1, 1.5, or 2 stop bits.

•The most used form of character encoding is the American

• Standard Code for Information Interchange (ASCII).

•This is a seven bit code which allows for 128 characters.

Page 11: 08-Serial Main Ppt

• When start and stop bits and a parity bit are added to the ASCII code, 9 to 11 bits are transmitted.

• • The rate of transmission of a data bit stream inbits per second (bps or b/s) is called the bit rate.

• • Standard bit rates are

• – 110 ( the old teletype or TTY rate),

• – 300 (early PC modems),

• – 1200, 2400, 9600, 14.4K, 19.2K, 28.8K, 38.4K, 57.6K

Page 12: 08-Serial Main Ppt

Asynchronous Data Framing

Idle (high): MarkLow: Space

Overhead? (parity, start, stop)

Page 13: 08-Serial Main Ppt

Synchronous

• With Synchronous communications, the two devices initially synchronize themselves to each other, and then continually send characters to stay in sync. Even when data is not really being sent, a constant flow of bits allows each device to know where the other is at any given time. That is, each character that is sent is either actual data or an idle character. Synchronous communications allows faster data transfer rates than asynchronous methods, because additional bits to mark the beginning and end of each data byte are not required. The serial ports on IBM-style PCs are asynchronous devices and therefore only support asynchronous serial communications.

Page 14: 08-Serial Main Ppt

Synchronous

• Since digital data are transmitted as a stream of bits, synchronization is required between the source and destination of the data.

• Synchronous transmission transmits a block of data and a clock signal or known bit pattern that can be used for synchronization.

Page 15: 08-Serial Main Ppt

Synchronous Data format

Page 16: 08-Serial Main Ppt

Serial CommunicationsComparison of transmission modes

• Asynchronous:– suitable for data transmitted at random intervals (e.g.

keyboard to computer)

– large overhead (20% or more)

– rather low data rates (up to 115.2 kbps, practically 38.4 kbps)

– simplicity and availability: UART and RS232 are present in any PC

– used in the great majority of dial-up connections

• Synchronous:– low overhead (long frames)

– high rates

– less prone to errors

Page 17: 08-Serial Main Ppt

RS-232 Standard

• EIA 232 = ITU-T V.24/V.28

• Specifies the interface between DTE and DCE:

• Even used in applications where there is no DCE– e.g. connecting computer to printer, magnetic card

reader, robot, … etc.

• Introduced in 1962 but is still widely used

• Stand for Recommended Standard

Page 18: 08-Serial Main Ppt
Page 19: 08-Serial Main Ppt

Vocabulary

• DTE– data terminal equipment

– e.g. computer, terminal

• DCE– data communication equipment

– connects DTE to communication lines

– e.g. modem

Page 20: 08-Serial Main Ppt

DTE Connections

Page 21: 08-Serial Main Ppt

25-Pin RS232 Connector

Source: Duck, Bishop & Read, Data Communications for Engineers, Addison-Wesley

Page 22: 08-Serial Main Ppt

9-Pin RS232 Connector

Page 23: 08-Serial Main Ppt

25 Pin Connector on a DTE device (PC connection)

Male RS232 DB25

Pin Number Direction of signal:

1 Protective Ground

2 Transmitted Data (TD) Outgoing Data (from a DTE to a DCE)

3 Received Data (RD) Incoming Data (from a DCE to a DTE)

4 Request To Send (RTS) Outgoing flow control signal controlled by DTE

5 Clear To Send (CTS) Incoming flow control signal controlled by DCE

6 Data Set Ready (DSR) Incoming handshaking signal controlled by DCE

7 Signal Ground Common reference voltage

8 Carrier Detect (CD) Incoming signal from a modem

20Data Terminal Ready (DTR) Outgoing handshaking signal controlled by DTE

22 Ring Indicator (RI) Incoming signal from a modem

Page 24: 08-Serial Main Ppt

TxD and RxD

• The TD (transmit data) wire is the one through which data from a DTE device is transmitted to a DCE device. This name can be deceiving, because this wire is used by a DCE device to receive its data. The TD line is kept in a mark condition by the DTE device when it is idle. The RD (receive data) wire is the one on which data is received by a DTE device, and the DCE device keeps this line in a mark condition when idle.

Page 25: 08-Serial Main Ppt

• RTS stands for Request To Send. This line and the CTS line are used when "hardware flow control" is enabled in both the DTE and DCE devices. The DTE device puts this line in a mark condition to tell the remote device that it is ready and able to receive data. If the DTE device is not able to receive data (typically because its receive buffer is almost full), it will put this line in the space condition as a signal to the DCE to stop sending data. When the DTE device is ready to receive more data (i.e. after data has been removed from its receive buffer), it will place this line back in the mark condition. The complement of the RTS wire is CTS, which stands for Clear To Send. The DCE device puts this line in a mark condition to tell the DTE device that it is ready to receive the data. Likewise, if the DCE device is unable to receive data, it will place this line in the space condition. Together, these two lines make up what is called RTS/CTS or "hardware" flow control.

Page 26: 08-Serial Main Ppt

• DTR stands for Data Terminal Ready. Its intended function is very similar to the RTS line. DSR (Data Set Ready) is the companion to DTR in the same way that CTS is to RTS. Some serial devices use DTR and DSR as signals to simply confirm that a device is connected and is turned on. The Software Wedge sets DTR to the mark state when the serial port is opened and leaves it in that state until the port is closed. The DTR and DSR lines were originally designed to provide an alternate method of hardware handshaking. It would be pointless to use both RTS/CTS and DTR/DSR for flow control signals at the same time. Because of this, DTR and DSR are rarely used for flow control.

Page 27: 08-Serial Main Ppt

• CD stands for Carrier Detect. Carrier Detect is used by a modem to signal that it has a made a connection with another modem, or has detected a carrier tone.

The last remaining line is RI or Ring Indicator. A modem toggles the state of this line when an incoming call rings your phone.

The Carrier Detect (CD) and the Ring Indicator (RI) lines are only available in connections to a modem. Because most modems transmit status information to a PC when either a carrier signal is detected (i.e. when a connection is made to another modem) or when the line is ringing, these two lines are rarely used.

Page 28: 08-Serial Main Ppt
Page 29: 08-Serial Main Ppt

Function of Signals

• DCD: data carrier detect– ON when two modems have negotiated successfully and the

carrier signal is established on the phone line

• RTS: request to send– ON when DTE wants to send data

– Used to turn on and off modem’s carrier signal in multi-point (i.e. multi-drop) lines

– Normally constantly ON in point-to-point lines

• CTS: clear to send– ON when DCE is ready to receive data

• SG: signal ground

Page 30: 08-Serial Main Ppt

Flow Control

• Means to ask the transmitter to stop/resume sending in data

• Required when:– DTE to DCE speed > DCE to DCE speed

(e.g. terminal speed = 115.2kbps and line speed = 33.6kbps, in order to benefit from modem’s data compression protocol)

» without flow control, the buffer within modem will overflow – sooner or later

– the receiving end takes time to process the data and thus cannot be always ready to receive

Page 31: 08-Serial Main Ppt

Hardware Flow Control

• RTS/CTS– the transmitting end activates RTS to inform the receiving

end that it has data to send

– if the receiving end is ready to receive, it activates CTS

– normally used between computer and modem

» computer is always ready to receive data but modem is not, because terminal speed > link speed

Page 32: 08-Serial Main Ppt

Software Flow Control

• Xon/Xoff– when the buffer within the receiving end is nearly full,

Xoff is sent to the transmitting end to ask it to stop

– when data have been processed by the receiving end and the buffer has space again, Xon is sent to the transmitting end to notify it to resume

– advantage: only three wires are required (TD, RD and GND)

– disadvantage: confusion arises when the transmitted data (e.g. a graphics file) contains a byte equal to 13H (Xoff)

Page 33: 08-Serial Main Ppt

Null Modem Connection

Page 34: 08-Serial Main Ppt

RS-232 – TTL conversion

Page 35: 08-Serial Main Ppt

TTL to RS-232

Line drivers and line receivers

Page 36: 08-Serial Main Ppt
Page 37: 08-Serial Main Ppt

RS-232 Frame Format

…0b0

1b nb p 1s 2sStart bit

ASCIIParity Stop bit

111101000001111

Idle A

Example

Page 38: 08-Serial Main Ppt

RS232 Logic Waveform

Page 39: 08-Serial Main Ppt

8251 Block Diagram

Page 40: 08-Serial Main Ppt
Page 41: 08-Serial Main Ppt

8251 Registers

Page 42: 08-Serial Main Ppt

Mode Register

Page 43: 08-Serial Main Ppt

Mode Instruction (Asynchronous)

Page 44: 08-Serial Main Ppt

Mode Instruction (Synchronous)

Page 45: 08-Serial Main Ppt

Command Register

Page 46: 08-Serial Main Ppt

Status Register

Page 47: 08-Serial Main Ppt
Page 48: 08-Serial Main Ppt
Page 49: 08-Serial Main Ppt
Page 50: 08-Serial Main Ppt

• Send 00H three times to AL

• Send 40H control word to reset

• Then send the mode word and the control word

Page 51: 08-Serial Main Ppt

Program

Asynchronous mode, even parity, 2 stop bits, 8 bit character, freq 160Khz and baud of 10k. Write an ALP to transmit 100 bytes of data starting at location 2000:5000H• 0FEH - mode word

11H control word

• MOV AX, 2000H

• MOV DS, AX

• MOV SI, 5000H

• MOV CL,64H

• MOV AL, 0FEH

• OUT 0FEH,AL

• MOV AX,11H

• OUT 0FEH,AL

• WAIT: IN AL,OFEH

• AND AL,01H

• JZ WAIT

• MOV AL,[SI]

• OUT OFCH, AL

• INC SI

• DEC CL

• JNZ WAIT

• MOV AH, 4CH

• INT 21H

Page 52: 08-Serial Main Ppt

ALP receive 100bytes and store at 3000:4000h• MOV AX,3000H

• MOV DS, AX

• MOV SI,4000H

• MOV CL,64H

• MOV AL,7EH

• OUT 0FEH,AL

• MOV AL,14H

• OUT OFEH,AL

• NXTBT: IN AL,OFEH

• AND 38H

• JZ READY

• MOV AL,14H

• OUT OFEH,AL

• READY: IN AL,OFEH

• AND 02H

• JZ READY

• IN AL, OFCH

• MOV [SI], AL

• INC SI

• DEC CL

• JNZ NXTBT

• MOV AH, 4CH

• INT 21H

Page 53: 08-Serial Main Ppt

256 Characters, sync mode, 6 bits, header is 3E and 3FH, odd parity

Page 54: 08-Serial Main Ppt

USB Overview• Universal Serial Bus (USB) is a hardware interface for low-

speed peripherals such as keyboards,  joysticks, scanners, printers, telephony devices, and MPEG-1 and MPEG-2 digital video. The electrical design of USB  limits the maximum cable length to 5 metres for full-speed devices and up to 3 metres for low-speed devices. Up to 5 hubs can be connected in series to allow for an extended cable run. Up to 127 devices (theoretical limit) can be attached to a single host computer. The hot-swap capability allows a USB device to be plugged in or unplugged without turning the system off. USB devices may be plugged into a USB receptacle on the PC, into a multi-port USB hub or into a USB device that also functions as a hub for other devices.

Page 55: 08-Serial Main Ppt
Page 56: 08-Serial Main Ppt
Page 57: 08-Serial Main Ppt
Page 58: 08-Serial Main Ppt
Page 59: 08-Serial Main Ppt
Page 60: 08-Serial Main Ppt
Page 61: 08-Serial Main Ppt

Universal Serial Bus

• Three drawbacks head any list of the most aggravating aspects of serial ports: low speed, complex cabling, and the limited number of ports. The Universal Serial Bus breaks through all three, combining a signaling rate of 12 Mbits/sec with a mistake proof wiring system and almost unlimited number of connections. The standard also supports lower speed devices sharing the same wiring system along with high speed devices. The low speed signaling rate is 1.5 Mbits/sec.

Page 62: 08-Serial Main Ppt

Data Transfer• The Full-speed USB 1.1 maximum bandwidth of 12 Mbits/sec

is equivalent to a data transfer speed of 1.5 Mbytes/sec with Hi-speed USB 2.0 - 480 Mbits/sec. A Low-speed rate of 1.5Mbits/sec is used for HI (Human Input Devices) such as keyboards, joysticks etc. A USB device indicates its speed by pulling either the D+ or D- line high to 3.3 volts. The pull-up resistors at the device end are also used by the host or hub to detect the presence of a device connected to the port.

• Data signals are transmitted on a twisted pair labelled D+ and D− using half-duplex differential signaling to combat the effects of electromagnetic noise on longer lines. D+ and D− usually operate together; they are not separate simplex connections. Transmitted signal levels are 0.0-0.3 volts for low and 2.8-3.6 volts for high. A NRZI (Non Return to Zero Invert) encoding scheme used to send data with a sync field to synchronize the host and receiver clocks

Page 63: 08-Serial Main Ppt

USB Power• The USB bus supplies 5V DC regulated power

(maximum 500mA)through each port on pins 1 and 4. These pins are longer than the data pins to ensure that the power connections mate first and un-mate last. Low-power devices that might normally require a separate AC adapter can therefore be powered via the USB cable, eliminating the need for associated AC adaptors. Bus-powered hubs derive all their power from the USB bus. Powered-hubs are powered from their own AC adapter and provide better power distribution to downstream devices. Port-switching USB hubs isolate all ports from each other so that a faulty device will not cause all other the devices on the same bus to also fail.