Скачать презентацию Serial Communications Introduction to UART and USART Intel Скачать презентацию Serial Communications Introduction to UART and USART Intel

424b64159985314c97a3f944f4c76dc3.ppt

  • Количество слайдов: 51

Serial Communications Introduction to UART and USART Intel 8250 and 8251 Serial Communications Introduction to UART and USART Intel 8250 and 8251

Outline • Concept of serial communications • Synchronous, Asynchronous • RS-232 standard • Hand Outline • Concept of serial communications • Synchronous, Asynchronous • RS-232 standard • Hand shaking • UART and USART chips • 8250 and 8251 chips

What is Serial Communication What is Serial Communication

Serial Communication Types • In Terms of Data on a Line – Asynchronous – Serial Communication Types • In Terms of Data on a Line – Asynchronous – Synchronous • In Terms of Number of Senders – Simplex – Half duplex – Full duplex

Transfer Types Transfer Types

Asynchronous Data Framing Sending Character ‘A’ = 0 x 41 on the Line Idle Asynchronous Data Framing Sending Character ‘A’ = 0 x 41 on the Line Idle (high): Mark Low: Space Overhead? (parity, start, stop)

Vocabulary • DTE – data terminal equipment – e. g. computer, terminal • DCE Vocabulary • DTE – data terminal equipment – e. g. computer, terminal • DCE – data communication equipment – connects DTE to communication lines – e. g. modem • Data Transfer Rate – Baud Rate – BPS Baud (Symbol representing n bits) Bit per second

RS-232 Standard • EIA 232 = ITU-T V. 24/V. 28 • Specifies the interface RS-232 Standard • EIA 232 = ITU-T V. 24/V. 28 • Specifies the interface between DTE and DCE: – V. 28 : mechanical and electrical characteristics – V. 24 : functional and procedural characteristics • 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

DTE Connections DTE Connections

Mechanical Characteristics • 25 -pin connector – 9 -pin connector is more commonly found Mechanical Characteristics • 25 -pin connector – 9 -pin connector is more commonly found in IBM-PC but it covers signals for asynchronous serial communication only • Use male connector on DTE and female connector on DCE • Note: all signal names are viewed from DTE

25 -Pin RS 232 Connector 25 -Pin RS 232 Connector

9 -Pin RS 232 Connector 9 -Pin RS 232 Connector

Electrical Characteristics • Single-ended – one wire per signal, voltage levels are with respect Electrical Characteristics • Single-ended – one wire per signal, voltage levels are with respect to system common (i. e. signal ground) • Mark: – 3 V to – 15 V – represent Logic 1, Idle State (OFF) • Space: +3 to +15 V – represent Logic 0, Active State (ON) • Usually swing between – 12 V to +12 V • Recommended maximum cable length is 15 m, at 20 kbps

TTL to RS-232 Line drivers and line receivers TTL to RS-232 Line drivers and line receivers

RS-232 Frame Format Example … Start bit ASCII Parity 111101000001111 Idle A Stop bit RS-232 Frame Format Example … Start bit ASCII Parity 111101000001111 Idle A Stop bit

RS 232 Logic Waveform RS 232 Logic Waveform

Function of Signals • TD: transmitted data • RD: received data • DSR: data Function of Signals • TD: transmitted data • RD: received data • DSR: data set ready – indicate whether DCE is powered on • DTR: data terminal ready – indicate whether DTR is powered on – turning off DTR causes modem to hang up the line • RI: ring indicator – ON when modem detects phone call

Function of Signals • DCD: data carrier detect – ON when two modems have 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

Flow Control • Means to ask the transmitter to stop/resume sending in data • 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. 2 kbps and line speed = 33. 6 kbps, 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

Hardware Flow Control • RTS/CTS – the transmitting end activates RTS to inform the 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

Software Flow Control • Xon/Xoff – when the buffer within the receiving end is 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 13 H (Xoff)

RS-232 (con) • Communication between two nodes Software Handshaking Hardware Handshaking data transmission CTS RS-232 (con) • Communication between two nodes Software Handshaking Hardware Handshaking data transmission CTS TD data transmission No Yes Send character RTS CTS RD receiver transmitter x-on receiver transmitter x-off Are you ready to RTS receive?

Null Modem Cables • Used to directly connect two DTEs together • Many possibilities Null Modem Cables • Used to directly connect two DTEs together • Many possibilities – depending on whether and how the two DTEs handshake (i. e. doing flow control)

Null Modem Cables Examples Null Modem Cables Examples

Other Standards Other Standards

UART in PC 115200*16=1843200 UART in PC 115200*16=1843200

8250/16450/16550 UART 8250/16450/16550 UART

Registers • Transmitter holding register • Receiver buffer register • Interrupt enable register Registers • Transmitter holding register • Receiver buffer register • Interrupt enable register

Registers • Interrupt identification register Registers • Interrupt identification register

Line Control Line Control

Modem Registers Modem Control Register Modem Status Register Modem Registers Modem Control Register Modem Status Register

Line Status Line Status

Divisor Register Divisor Register

Example Program the divisor Latch for 300 baud. Assume Xin=1. 8432 MHz The Base Example Program the divisor Latch for 300 baud. Assume Xin=1. 8432 MHz The Base Address: 0 x 3 F 8

Example 2 Program the divisor Latch for 2400 baud. Assume Xin=1. 8432 MHz The Example 2 Program the divisor Latch for 2400 baud. Assume Xin=1. 8432 MHz The Base Address: 0 x 3 F 8

Example 3 Program 8250 for 2400 baud, 8 data bit, even parity and 1 Example 3 Program 8250 for 2400 baud, 8 data bit, even parity and 1 stop bit. Assume Xin=1. 8432 MHz The Base Address: 0 x 3 F 8 MOV MOV OUT MOV INC OUT MOV OUT AL, 80 H DX, 3 FBH DX, AL AX, 48 DX, 3 F 8 H DX, AL AL, AH DX DX, AL AL, 00011011 DX, 3 FBH DX, AL ; Accessing DLAB ; Line Control Register Address ; baud=2400 115200: 48=2400 ; Low byte of Divisor ; DLAB, Break, Even, 1 stop, 8 data ; LCR

Synchronous Protocols Synchronous Protocols

CRC In SDLC: G(X) = x**16 + x**12 + x**5 + 1 CRC In SDLC: G(X) = x**16 + x**12 + x**5 + 1

8251 Block Diagram 8251 Block Diagram

8251 Registers 8251 Registers

Mode Register Mode Register

Mode Instruction (Asynchronous) Mode Instruction (Asynchronous)

Mode Instruction (Synchronous) Mode Instruction (Synchronous)

Command Register Command Register

Status Register Status Register

8251 Timing 8251 Timing

8251 USART Interface 8251 D[7: 0] RD WR A 0 CLK A 7 A 8251 USART Interface 8251 D[7: 0] RD WR A 0 CLK A 7 A 6 A 5 A 4 A 3 A 2 A 1 IO/M Tx. D RD WR C/D CLK Rx. D Tx. C RS 232

Programming 8251 q 8251 mode register 7 6 5 Number of Stop bits 00: Programming 8251 q 8251 mode register 7 6 5 Number of Stop bits 00: 01: 10: 11: invalid 1 bit 1. 5 bits 2 bits 4 3 Parity enable 0: disable 1: enable Parity 0: odd 1: even 2 1 0 Mode register Baud Rate 00: 01: 10: Character length 11: 00: 5 bits 01: 6 bits 10: 7 bits 11: 8 bits Syn. Mode x 1 clock x 16 clock x 64 clock

Programming 8251 q 8251 command register EH IR RTS ER SBRK Rx. E DTR Programming 8251 q 8251 command register EH IR RTS ER SBRK Rx. E DTR Tx. E: transmit enable DTR: data terminal ready Rx. E: receiver enable SBPRK: send break character ER: error reset RTS: request to send IR: internal reset EH: enter hunt mode command register

Programming 8251 q 8251 status register DSR SYNDET FE Tx. RDY: Rx. RDY: Tx. Programming 8251 q 8251 status register DSR SYNDET FE Tx. RDY: Rx. RDY: Tx. EMPTY: PE: OE: FE: SYNDET: DSR: OE PE Tx. EMPTYRx. RDY Tx. RDY transmit ready receiver ready transmitter empty parity error overrun error framing error sync. character detected data set ready status register

Simple Serial I/O Procedures q Read q Write start Check Rx. RDY Check Tx. Simple Serial I/O Procedures q Read q Write start Check Rx. RDY Check Tx. RDY Is it logic 1? No Is it logic 1? Yes Read data register* end * This clears Rx. RDY No Yes Write data register* end * This clears Tx. RDY