Urządzenia peryferyjne RS-232 Wykład 2
Transmisja szeregowa Poprzez kanały telekomunikacyjne Zaleta: niskie koszty Wymaga konwersji szeregowo/równoległej np. rejestr przesuwny Dwie metody: asynchroniczna lub synchroniczna 2
Transmisja asynchroniczna Używa bitów startu (0) i bitów stopu (1) Przerwa między dwoma bajtami: idle state lub bity stopu Tzn. transmisja asynchroniczna na poziomie bajtów jest synchronizowana na poziomie bitów Dobra dla wolnych transmisji, terminale, urządzenia pomiarowe 3
Komunikacja szeregowa Bity startu informuje o tym że transmisja się rozpoczyna Następne 5-8 bitów reprezentuje dane Liczba bitów jest konfigurowalna 8-bitów jest najbardziej popularne Stop Bit(s) Start Bit 5-8 Data Bits Parity Bit 4
Transmisja synchroniczna Strumień bitów tworzy ramki ( frames ) Brak przerw Bardzo ważny jest zegar często dodatkowa linia Synchronizacja bajtów w warstwie danych (np.. 16h) Zaleta: prędkość duża 5
DTE i DCE DTE (Data Terminal Equipment) Jakie kolwiek źródło danych cyfrowych Często nie komunikują się wzajemnie DCE (Data Circuit-terminating Equipment) Jakiekolwiek urządzenie transmitujące dane Modemy 6
DTE-DCE Interfejs standardowy każdy DTE musi mieć swoje DCE które komunikuje się z innym DCE EIA-232/442/449, ITU-T V series/x series V.24 (CCITT) 7
Interfejs EIA-232 1962, od 1969 RS-232C, stanadard 1986 (V.24) Mechaniczna specyfikacja DB-25, 15-metrowy kabel.. Również DB-9 i obecnie RJ11, RJ45 8
Interfejs EIA-232 Kodowane NRZ-L (nonreturn-to-zero level) Zakres sygnałów: [3, 15] i [-15, -3] V Dane: dodatnie dla bitu 0, ujemne 1 Sygnały kontrolne: + ON, - OFF 9
Dane i sygnały kontrolne w EIA- 232 10
Interfejs szeregowy RS-232 Format znaków 11
RS-232 parzystość Odd Parity Even Parity No Parity 12
Interfejs szeregowy RS-232 Przebiegi podstawowe 13
Sygnały interfejsu 14
Specfikacja funkcjonalna Możliwy pełen duplex 15
Interfejs szeregowy RS-232 Opis wyprowadzeń 16
Interfejs szeregowy RS-232 Opis wyprowadzeń 17
Interfejs szeregowy RS-232 Zależności czasowe sygnałów 18
19
Null Modem DTE-DTE interfejs bez DCEs Dla złącza DB-25 20
Interfejs szeregowy RS-232 Kabel Null-Modem pełny 21
22
Interfejs szeregowy RS-232 Kabel Null-Modem uproszczony 23
Ograniczenia długości EIA/TIA-232 Typowa pojemność 40pF/m => 100m = 4nF. Prędkość (body) Długość (metres) 2400 65 4800 34 9600 16 19200 8 38400 4 57600 3 115200 1.5 24
Rodzaje złączy 26
Interfejs I 2 C Popular for peripheral interfacing Two Wire (plus GND) bi-directional interface 0 & 5V logic levels Suitable for short distance communication 27
Konwerter RS232 do I 2 C 28
OneWire 29
Kontroler Super I/O Kontroler interfejsów 30
Kontroler interfejsów Adresy interfejsów adresy portów są 0000:0400 0407 0000:0400 F8 03 F8 02 E8 03 E8 02 31
To/From CPU 8 bit data UART 16550A Data Bus Buffer CPU Interface 0x3F8 +0 RBR Start I/O Port Address +0 +1 +2 +2 THR IER IIR FCR Transmit Buffer (FIFO) (16 bytes) +3 +4 +5 LCR MCR LSR Receive Buffer (FIFO) (16 bytes) Serial port +6 MSR +7 SR Registers 32
UART rejestry RBR: Receive Buffer Registers Contains the byte received if no FIFO is used IER: Interrupt Enable Register Is used to enable and disable interrupts that can be generated by UART. LSR: Line Status Register Shows the current state of the communication over Tx and Rx serial lines. IIR: Interrupt Identification Register Tells what kind of interrupt it is. FCR: FIFO Control Register Is used to control the FIFO queues. LSR: Line Status Register Used to set the characteristics (parameters) of RS-232 line. MCR: Modem Control Register Is used for handshaking operations with the attached modem device. MSR: Modem Status Register Contains info about the modem state. THR: Transmit Holding Register Contains the byte that is to be sent. 33
Line Control Register Bit Value Comment 0,1 Bit1 bit0 Data word length 0 0 5 bits 0 1 6 bits 1 0 7 bits 1 1 8 bits 2 0 1 stop bit 1 2 stop bits 3,4,5 Bit5 Bit4 Bit3 x x 0 No parity 0 0 1 Odd parity 0 1 1 Even parity 1 0 1 High parity 1 1 1 6 0 1 7 0 Access to rx buffer, tx buffer and IER register 1 Divisor latch access bit 34
Line Status Register (LSR) Bit Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Notes Error in Received FIFO Empty Data Holding Registers Empty Transmitter Holding Register Break Interrupt Framing Error Parity Error Overrun Error Data Ready 35
Wektor przerwań INT (Hex) IRQ Common Uses 08 0 System Timer 09 1 Keyboard 0A 2 Redirected 0B 3 Serial Comms. COM2/COM4 0C 4 Serial Comms. COM1/COM3 0D 5 Reserved/Sound Card 0E 6 Floppy Disk Controller 0F 7 Parallel Comms. 70 8 Real Time Clock 71 9 Reserved 72 10 Reserved 73 11 Reserved 74 12 PS/2 Mouse 75 13 Maths Co-Processor 76 14 Hard Disk Drive 77 15 Reserved 36
Polling based I/O example Serial Cable Computer A Computer B Our driver UART UART Our driver com1 com1 A serial port application (*) (or a driver) Copyright 1997 CRAIG PEACOCK <cpeacock@senet.com.au> See http://www.senet.com.au/~cpeacock/serial1.htm For More Information 37
Gdzie to jest w moim komputerze? 38