DOC PREVIEW
USF CS 635 - Lecture Notes

This preview shows page 1-2-3-20-21-22-41-42-43 out of 43 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

The UART projectProject’s purposeUniversal Asynchronous Receiver-TransmitterTx and RxPC-to-PC communicationsUsing ‘echo’ and ‘cat’Kudlick ClassroomSlide 8Requires a device-file node‘write()’ and ‘read()’DCE and DTEPC with a modemSerial data-transmissionSerial data receptionNormal 9-wire serial cableSignal functionsSignal functions (continued)9-wire null-modem cableThe 16550 UART registersRate of data-transferDivisor LatchHow timing worksProgramming interfaceModem Control RegisterModem Status RegisterLine Status RegisterLine Control RegisterInterrupt Enable RegisterFIFO Control RegisterInterrupt Identification RegisterResponding to interruptsUsage flexibilityHow to transmit a byteHow to receive a byteHow to implement in C/C++How to initialize ‘loopback’ modeHow to adjust the cpu’s IOPLIn-class experimentsExperiment #1Experiment #2Experiment #3Experiment #4Is your cable working?The UART projectApplying what we’ve learned about Linux device-drivers to the PC’s serial-port controllerProject’s purpose•Allow you to gain experience encountering the kinds of issues that commonly arise in crafting software to operate real hardware: –Learning the hardware device’s capabilities–Deciding which driver-methods to implement–Accommodating your platform’s interfaces –Exploiting the OS kernel’s support-functions–Devising a strategy for testing and debuggingUniversal Asynchronous Receiver-Transmitter (UART)See our CS635 course website at: <http://cs.usfca.edu/~cruse/cs635f07>for links to the UART manufacturer’s documentation and to an in-depth online programming tutorialTx and Rx•The UART has a transmission-engine, and also a reception-engine, which are able to operate simultaneously (i.e., “full-duplex”)•Software controls the UART’s operations by accessing several registers, using the x86 processor’s ‘in’ and ‘out’ instructions•Linux provides some convenient ‘macros’ that ‘hide’ the x86 machine-code detailsPC-to-PC communicationsrackmountPC system studentworkstationKVM cablerackmountPC system studentworkstationKVM cable‘null-modem’ serial cable ethernet cablesUsing ‘echo’ and ‘cat’•Your device-driver module (named ‘uart.c’) is intended to allow unprivileged programs that are running on a pair of adjacent PCs to communicate via a “null-modem” cable $ echo Hello > /dev/uart$ _$ cat /dev/uartHello _Receiving…Transmitting…Kudlick Classroom08 09 10 15 16 17 18 19 20 28 29 3004 05 06 07 11 12 13 14 24 25 26 2701 02 03 21 22 23Indicates a “null-modem” PC-to-PC serial cable connectionlecternLinux char-driver components init exit fopsfunctionfunctionfunction. . .Device-driver LKM layout registers the ‘fops’ unregisters the ‘fops’ module’s ‘payload’ is a collection of callback-functions having prescribed prototypes AND a ‘package’ of function-pointers the usual pair of module-administration functionsRequires a device-file node•Our System Administrator has created the device-file needed for your driver-module:root# mknod /dev/uart c 84 0root# chmod a+w /dev/uart•Your driver-module needs to ‘register’ your package of driver-methods (i.e., functions) in its initialization routine (and ‘unregister’ them later in its cleanup routine)‘write()’ and ‘read()’•Obviously your driver-module’s ‘payload’ will have to include ‘methods’ (functions) which perform the ‘write()’ and ‘read()’ operations that applications will invoke•You may decide your driver needs also to implement certain additional ‘methods’ •A little history is helpful for understanding some of the UART device’s terminologyDCE and DTE•Original purpose of the UART was for PCs to communicate via the telephone network•Telephones were for voice communication (analog signals) whereas computers need so exchange discrete data (digital signals)•Special ‘communication equipment’ was needed for doing the signal conversions (i.e. a modulator/demodulator, or modem)PC with a modemcomputer terminalmodem serial cablephone wireDataTerminalEquipment(DTE)DataCommunicationsEquipment(DCE)Serial data-transmission0 1 1 0 0 0 0 1The Transmitter Holding Register (8-bits)0 1 1 0 0 0 0 1The transmitter’s internal ‘shift’ registerclockSoftware outputs a byte of data to the THRThe bits are immediately copied into an internal ‘shift’-registerThe bits are shifted out, one-at-a-time, in sync with a clock-pulse 1-0-1-1-0-0-0-0-1-0start bitstop bitdata-bits clock-pulses trigger bit-shiftsSerial data receptionclockinput voltage clock-pulses trigger voltage-sampling and bit-shifts at regular intervals 0 1 1 0 0 0 0 1The receiver’s internal ‘shift’ register1-0-1-1-0-0-0-0-1-0start bitstop bitdata-bits0 1 1 0 0 0 0 1The Receiver Buffer Register (8-bits)Software can input the received byte from the RBRNormal 9-wire serial cable1569169Carrier DetectRx dataTx dataData Terminal ReadySignal GroundData Set ReadyRequest To SendClear To SendRing Indicator5Signal functions•CD: Carrier Detect The modem asserts this signal to indicate that it successfully made its connection to a remote device •RI: Ring Indicator The modem asserts this signal to indicate that the phone is ringing at the other end of its connection•DSR: Data Set Ready Modem to PC •DTR: Data Terminal Ready PC to ModemSignal functions (continued)•RTS: Request To Send PC is ready for the modem to relay some received data •CLS: Clear To Send Modem is ready for the PC to begin transmitting some data9-wire null-modem cableCDRxDTxDGNDDSRDTRRTSCTSRICDRxDTxDGNDDSRDTRRTSCTSRI Data TerminalEquipmentDataTerminalEquipmentno modemsThe 16550 UART registersTransmit Data RegisterReceived Data RegisterInterrupt Enable RegisterInterrupt Identification RegisterFIFO Control Register Line Control Register Modem Control Register Line Status RegisterModem Status RegisterScratch Pad RegisterDivisor Latch Register16-bits (R/W)8-bits (Write-only)8-bits (Read-only)8-bits (Read/Write)8-bits (Read-only)8-bits (Write-only)8-bits (Read/Write)8-bits (Read/Write)8-bits (Read-only)8-bits (Read-only)8-bits (Read/Write)Base+0Base+0Base+1Base+2Base+2Base+3Base+4Base+5Base+6Base+7Base+0Rate of data-transfer•The standard UART clock-frequency for PCs equals 1,843,200 cycles-per-second•Each data-bit consumes 16 clock-cycles •So the fastest serial bit-rate in PCs would be 1843200/16 = 115200 bits-per-second•With one


View Full Document

USF CS 635 - Lecture Notes

Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?