Lecture 13: DUART serial I/O, part I The bi picture of serial commuicatios Aalo commuicatios Modems Modulatio-demodulatio methods Baud rate Vs. Bits Per Secod Diital serial commuicatios Simplex, half-duplex ad full-duplex Sychroous serial trasmissio Asychroous serial trasmissio The RS-232C stadard Mechaical ad electrical specs Cotrol lies Hadshaki Null modem Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 1
The bi picture of serial commuicatios Diital (RS232C) Aalo (Public Switched Telephoe Network) Diital (RS232C) DTE (Data Termial Equipmet) DCE (Data Commuicatios Equipmet) DCE DTE DTE 68000 CPU TTL 68681 DUART TTL MAX232 driver RS-232 Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 2
Itroductio to modems The POTS (Plai Old Telephoe System) was desied to trasmit voice-bad aalo sials i the rae 300Hz to 3300Hz It is ot appropriate for trasmissio of diital sials due to their hih-frequecy compoets (i.e.: sharp, ede trasitios). If a sequece of biary sials was preseted to oe ed of a telephoe etwork, the diital sials would be so severely distorted that they would be urecoizable at the receivi ed of the circuit I order to trasmit a diital sial, it must be coverted to a aalo sial withi the badwidth of the POTS A bit stream is coverted ito a aalo sial at the seder by Modulatio The aalo sial is coverted back ito a bit stream at the receiver by Demodulatio The D/A ad A/D coversio is performed by a device called modem or modulator-demodulator There are three basic modulatio methods: Amplitude modulatio Frequecy modulatio Phase modulatio Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 3
Amplitude, Frequecy ad Phase Modulatio Amplitude Modulatio (AM) A sile carrier frequecy is used to trasmit data Biary values are coverted to differet amplitudes of the carrier sial Suitable oly for low speed trasmissio Frequecy modulatio (FM) Two carrier frequecies of the same amplitude are used The hiher frequecy is associated with biary 1, the lower frequecy with biary 0 Used for 1200 bps modems or slower speeds FM is widely used because it has a better tolerace to oise tha AM Phase modulatio (PM) A sile carrier frequecy is used to trasmit data The phase of the sial is chaed accordi to the biary value to be trasmitted PM is widely used ad has fairly similar characteristics to FM Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 4
Uits for speed of trasmissio Baud rate Measures the switchi speed of a sial (the umber of times per secod that a lie chaes state) Bits per secod (bps) Measures the rate at which iformatio flows across a data lik Bauds ad bps are ot the same For a biary two-level sial, a data rate of 1 bps is equivalet to 1 Baud But suppose a data trasmissio system that uses sials with 16 possible discrete levels. Each sial elemet ca have oe of 16=24 differet values, that is, each discrete level ecodes 4 bits If the 16-level sials are trasmitted at 1200 Baud, the data rate is 4x1200=4800 BPS I eeral, baud rates over the POTS is limited to 2400 Bauds due to badwidth limitatios, so data rates hiher tha 2400 bps are achieved by sophisticated modulatio techiques ad data compressio For example, usi PM with phase shifts multiple of 90 we ca double the data rate, as i differetial phase modulatio Hih-speed modems operate by simultaeously chai the amplitude ad phase of a sial. This modulatio techique is called quadrature amplitude modulatio (QAM) Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 5
Modes of chael operatio Simplex Data i a simplex chael is always oe way Simplex chaels are ot ofte used because it is ot possible to sed back error or cotrol sials to the trasmit ed. Its like a oe way street A example of simplex is televisio Half Duplex A half duplex chael ca sed ad receive, but ot at the same time; oly oe ed trasmits at a time, the other ed receives Its like a oe-lae bride where two way traffic must ive way i order to cross. Full Duplex Data ca travel i both directios simultaeously. There is o eed to switch from trasmit to receive mode like i half duplex Its like a two lae bride o a two-lae hihway simplex half-duplex full-duplex From ow o we will iore how the two computers are physically coected. They could be remote systems coected throuh a telephoe lie, or they could be local systems coected with a simple serial cable Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 6
Sychroous Trasmissio I sychroous trasmissio, the clocks at the trasmissio ad receptio eds must be permaetly sychroized by either Trasmitti the clock sial o a separate wire (too expesive) Embeddi the clock sial i the data stream (preferred). A example of embedded clock is Phase Ecodi Procedure From the received phase-ecoded sial it is possible to recover both the data stream ad the clock sial To iitiate trasmissio, the trasmitter first seds out sychroizatio characters to the receiver The receiver reads the sychroizatio bit patter ad compares it with a kow syc patter. Oce they are idetified as bie4 the same, the receiver beis to read character data off the commuicatios lie Trasfer of data cotiues util the complete block of data is received or sychroizatio is lost If lare blocks of data are bei set, the sychroizatio characters may be periodically reset to assure that sychroizatio is maitaied Sychroous trasmissio is typically used i hihspeed applicatios Phase-ecoded sychroous serial bit trasmissio Data stream before ecodi Clock Phase ecoded sial 0 0 1 1 1 0 1 0 Loical zero represeted by a falli ede Loical oe represeted by a risi ede Trasmit System 1 Clock System 2 (embedded) Directio of trasmissio Receive Groud DATA SYN CHAR #2 SYN CHAR #1 Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 7
Asychroous Trasmissio I asychroous trasmissio there is o eed for the clocks to be sychroized Data to be trasmitted is set oe character at a time At the received ed of the trasmissio sychroizatio is performed by examii sychroizatio bits that are icluded at the beii ad ed of the character The format of a typical asychroous character is the followi Start bit (1 bit): a loical 0 (also called a space) that is used to idicate the beii of a character Data bits (7-8 bits): they cotai the iformatio that is bei trasmitted. The data wordleth ca be either 7 or 8 bits Parity bit (1-0 bits): optioal, used for error checki. If odd parity is used, the parity bit is set to 1 or 0 such that the total umber of 1-bits, icludi the data bits ad the parity bit, is odd. Stop bit (1-2 bits): a loical 1 (also called a mark ) that is used to idicate the ed of the trasmissio Trasmit Receive System 1 System 2 Groud A total of 12 possible formats are possible sice we ca have 7 or 8 data bits eve, odd or o parity bits 1 or 2 stop bits Asychroous data trasmissio is the most popular serial mode, but is hihly iefficiet: for 7 data bits ad 2 stop bits, oly 70% of the trasmissio cotais iformatio is more suited for ASCII text. For 8-bit biary data it is quite difficult to embed cotrol characters (i.e., tape start or stop) withi the data stream Idle state Parity bit Stop bit(s) MSB Directio of trasmissio Data bits LSB Start bit Idle state Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 8
The RS232 stadard RS232C (Recommeded Stadard 232 versio C) was published i 1969 Oriially desied for DTE (computer) to DCE (modem) commuicatios Curretly bei used for more eeral applicatios, such as DTE to DTE coectios RS232C specifies Mechaical iterface (DB-25) Female coector is coected to DCE ad male coector to DTE. Short cables of less tha 15 meters (50 feet) are recommeded. The pi assimets detailed above must be used. Electrical iterface All circuits carry bi-polar low-voltae sials, measured at the coector with respect to sial roud, ad may ot exceed ±25 volts. Sials are valid i the rae ±3 volts to ±25 volts. Sials withi the rae -3 volts to +3 volts are cosidered ivalid. Differet from TTL levels (0-5V) Cotrol Lies Need drivers ad receivers to covert voltaes (betwee the ACIA/DUART ad the RS232 lie) MAX232 by Maxim combies driver ad receiver i a sile packae The lies available (ad their fuctio) to coect DTE ad DCE RS232C-to-TTL sial coversio TTL RS232C Loic Voltae Loic Voltae Hih(1) 2.4 to 5 volts MARK -3 to -25 volts Low(0) 0 to 0.8 volts SPACE +3 to +25 volts Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 9
Basic RS232 Cotrol Lies Request To Sed (RTS), Pi 4 This sial lie is asserted by the computer (DTE) to iform the modem (DCE) that it wats to trasmit data. If the modem decides this is okay, it will assert the CTS lie. Typically, oce the computer asserts RTS, it will wait for the modem to assert CTS. Whe CTS is asserted by the modem, the computer will bei to trasmit data. Clear To Sed (CTS), Pi 5 Asserted by the modem after receivi a RTS sial, idicati that the computer ca ow trasmit. Data Termial Ready (DTR), Pi 20 This sial lie is asserted by the computer, ad iforms the modem that the computer is ready to receive data. Data Set Ready (DSR), Pi 6 This sial lie is asserted by the modem i respose to a DTR sial from the computer. The computer will moitor the state of this lie after asserti DTR to detect if the modem is tured o. Data Carrier Detect (DCD), Pi 8 This cotrol lie is asserted by the modem, iformi the computer that it has established a physical coectio to aother modem. It would be poitless a computer trasmitti iformatio to a modem if this sial lie was ot asserted. If the physical coectio is broke, this sial lie will chae state. Trasmit Data (TD), Pi2 The lie where the data is trasmitted from the computer to the modem. Receive Data (RD), Pi 3 The lie where data is received (trasmitted from the modem to the computer.) Computer RTS CTS DSR DTR DCD TD RD Modem RTS CTS DSR DTR DCD TD RD Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 10
Examples of hadshaki Whe the computer wats to trasmit data to the modem RTS is asserted by the DTE (1) to idicate that the DTE wishes to sed data CTS is asserted by the DCE (2) to idicate that the DCE is ready to receive data DTE trasmits data throuh TD (3) DTE completes data trasmissio (4) RTS is eated by the DTE (5) to idicate that the DTE has fiished trasmitti data CTS is eated by DCE (6) RTS CTS TD Computer TD RTS CTS Modem TD RTS CTS 1 2 3 4 5 6 Whe the modem wats to trasmit data to the computer The DCE asserts DCD To idicate that a data carrier is preset ad to trasmit data The DTE must be prepared to receive data ay time DCD is asserted Computer RD DCD Modem RD DCD Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 11
Null modem The RS-232C iterface was desied to coect computers to modems However, may of today s RS-232C applicatios are for coecti a computer (DTE) to a peripheral (such a priter, also cosidered a DTE), rather tha to a modem (DCE) I order to coect a DTE to a DTE we must cross some of the cotrol sials the DTE sials from oe computer are swapped over as iputs to supply the DCE expected sials o the other DTE This DTE-DTE iterface is accomplished with a special coector cable called a ull modem A ull modem simulates a DTE-DCE-DCE-DTE circuit A ull modem has a female DB-25 coector o both eds The cotrol lies are wired as idicated i the fiure DTE Ri idicator Data termial ready Data set ready Carrier detect Clear to sed Request to sed Received data Trasmitted data Protective roud Sial roud DTE Ri idicator Data termial ready Data set ready Carrier detect Clear to sed Request to sed Received data Trasmitted data Protective roud Sial roud Microprocessor-based System Desi Ricardo Gutierrez-Osua Wriht State Uiversity 12