Lect4 - MESL - University of California, San Diego
Download
Report
Transcript Lect4 - MESL - University of California, San Diego
COSMOS Summer 2008
Peripheral Interfaces: USB
Rajesh K. Gupta
Computer Science and Engineering
University of California, San Diego.
©2008 R. Gupta, UCSD
Roadmap
• Topic:
– From electrical interfaces to mechanical
– From serial to parallel and back
• This lecture
– Concepts covered: Interface standardization, character coding,
serial data transfers, S2P/P2S conversion, Star network, Host
controller
• Next lecture
– Capacitive Sensing
• Reference
– None
©2008 R. Gupta, UCSD
Keywords:
RS232c, Dsub connector,
UART, RTS/CTS,
XON/XOFF, USB, USB Hub,
USB host, CRC
Upstream connector
Downstream connector
What is this connector?
9-pin RS232C: DE-9
A “Serial” Port
Then What Are These?
From RS232(c) to USB
• “D-Sub” connectors
–
A: 15 pin
–
B: 25 pin
–
C: 37 pin
–
D: 50 pin
–
E: 9 pin
• RS232 was DB25
–
RS232c was DE9
• Specified by EIA in 1969
–
Electricals (voltage levels)
–
Signaling rate, timing, slew-rate
–
Mechanicals
–
But not: character encoding,
character framing, protocols
Question 1: How many keys on your keyboard?
Question 2: How many bits it will take to encode these?
What is ASCII?
• American Standard Code for Information Interchange
– Published in 1963, revised 1967, 1986
• 128 characters, incl. 33 non-printing or control
– 94 printable characters: 26 + 10 + 11-25 symbols
– Is SPACE printable?
• 8-bit extension by MAC OS Roman
• Unicode and Universal Character Set (UCS)
– UTF-8, UTF-16, UTF-32
Signaling
• Half and Full Duplex
• Serial signaling
– Send one bit at a time
• Asynchronous serial communication
– Send a START signal prior to each byte
– And a STOP signal after each byte
– Generally use more than 8-bit to transmit a byte (10 to 12)
• UART: Universal Asynchronous Receiver Transmitter
– Again, no shared clock. The RX must lock onto data and detect
individual bits
– TX is a Parallel-to-Series converter
• RX is a Series-to-Parallel converter
“Handshakes”
• RTS = Request to Send
– TX asserts RTS
• CTS = Clear to Send
– RX asserts CTS
• This gives you flow control
– That is, data transfer can proceed at a rate that is acceptable
• Software version of this flow control is XON/XOFF
Historical Amusements
• RS232C originally designed for connecting a teletype
(DTE) to a modem (DCE)
–
The modem connected over the phone line to other modems
–
Question: Why ‘modem’? Hint: interface to the telephone line.
–
In truth, DTE, DCE is a bit arbitrary
• RS232C is ‘unbalanced’
–
Logical High = typically -12V (-5 to -15 V)
–
Logical Low = typically +12V (+5 to +15 V)
–
This means that one typically needs interface circuits to the
microprocessor (level shifters)
• 7-bit data frames
–
(instead of more common 8-bit)
–
You may receive email that specifies 7-bit character set just in case it is
routed via a serial connection that supports only 7-bit transmission
Standardizing the Standard: USB
• RS232C is not standard enough
– Too much flexibility (on data rate, parity, flow control)
• Now, the ‘OS’ is aware of the device interface
– That also means lot of software support needed.
• USB 1.1: 12 Mbps (Normal), 1.5 Mbps (Low)
• USB 2.0: 480 Mbps (High)
• USB 3.0: 4.8 Gbps (Super)
• Up to 127 devices. One standard cable.
– Devices identify themselves. Not the interface.
USB
• Shielded 4-wire cable
1
Vbus
USB device power (+5 V)
Red
3
D+
Differential data line
Green
2
D-
Differential data line
White
4
GND
Power and signal ground
Black
• One host in a network: host controller
–
Upstream versus downstream connection and connectors (A versus B)
• Host controller either directly connects to device (star) or through
a hub (tiered star)
–
Because of the connectors, no device-to-device connections
• When a device is attached to the network
–
–
–
Based on its identification, the host OS determines the software driver to
be used,
device is assigned a unique address and
host requests its internal configuration.
Classes of Devices
• Host controller know about the following class of devices
–
–
–
–
–
–
–
–
–
–
–
–
Audio
HID
Hub
IrDA
Mass storage: HD, CDROM, DVD
Monitor
Communications
Physical interface device
Power
Printer
Imaging
Common class…
USB Packets
• All data transfers under the control of the host controller
• Four type of data transfers
– Control transfer: configure the bus and devices on the bus
– Bulk transfer: move data asynchronously
– Isochronous transfer: move time-critical data (e.g, audio)
– Interrupt transfer: retrieve data at regular intervals
• A packet contains
– SYNC byte, Packet ID, Content, CRC
• Four type of packets
– Token, data, handshake, preamble
Recap
• Serial interfaces are simpler and cost effective
in embedded applications
• Standardization helps in proliferating their use
• The data interface can also be used to supply
power
– Typically use ‘unused’ pins in the standard
• E.g., A RTS ‘powers up’ a device
– PoE, PoweredUSB, …
• Next: Capacitive Sensors.
©2008 R. Gupta, UCSD