usb part 1: wires, packets, transactions2015/07/23 · arduino uno does it though inrush current...
TRANSCRIPT
![Page 1: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/1.jpg)
USBPart 1: Wires, packets, transactions
David Grayson2015-07-23
![Page 2: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/2.jpg)
Which USB are we talking about?
● Full speed (12 Mbps)● Universal Serial Bus Specification
Revision 2.0, April 27, 2000● 650 page document● Engineering Change Notices (ECNs)
![Page 3: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/3.jpg)
Types of USB
● Low Speed: 1.5 Mbps● Full Speed: 12 Mbps● High Speed: 480 Mbps● SuperSpeed: up to 5000 Mbps● SuperSpeed+: up to 10000 Mbps
![Page 4: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/4.jpg)
Bus topology
● One host– Detects devices, initiate communication
● Multiple devices– Provides one or “functions” to the host
![Page 5: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/5.jpg)
USB 2.0 section 4.1.1
![Page 6: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/6.jpg)
Topology is enforced by connectors
A plugB plug
B receptacle
A receptacle
http://uk.farnell.com/multicomp/mc32593/usb-2-0-type-a-recetpacle-th/dp/1696534
![Page 7: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/7.jpg)
USB 2.0 section 6.4.4
Prohibited cable assemblies
“USB is optimized for ease of use. The expectation is that if the device can be plugged in, it will work.”
![Page 8: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/8.jpg)
Prohibited cable assembly:Extension cables assembly
USB 2.0 section 6.4.4http://www.amazon.com/Belkin-USB-Extension-Cable-10-Feet/dp/B00001ZWXA
![Page 9: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/9.jpg)
Prohibited cable assembly:Cable that violates USB topology
rules
USB 2.0 section 6.4.4 http://www.showmecables.com
But USB On-the-go (OTG) is fine.
![Page 10: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/10.jpg)
Prohibited cable assembly:Standard detachable cables for
low-speed devices ● “Using a long high-/full-speed cable exceeds
the capacitive load of low-speed.”
https://www.sparkfun.com/products/9825https://learn.adafruit.com/introducing-trinket/introduction
![Page 11: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/11.jpg)
● Chapter 6 has more mechanical specifications● My favorite part:
USB 2.0 section 6.7
7.9 lbs
2.2 lbs
![Page 12: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/12.jpg)
That's enough mechanical stuff.Let's talk about the electronics….
![Page 13: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/13.jpg)
USB wires
USB 2.0 section 6.3
![Page 14: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/14.jpg)
Power distribution: Voltage
USB 2.0 section 7.2
Devices typically get 5.0 V but it could be as low as 4.35 V.
![Page 15: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/15.jpg)
Current limits
● “Unit load” is defined to be 100 mA● Low power device: 1 unit load (100 mA)● High power device: up to 5 unit loads (500 mA)● Devices cannot draw more than 1 unit load until
the device is configured by the host.● (Later USB specifications allow for a lot more
current.)● Suspend mode: 2.5 mA
USB 2.0 section 7.2.1, Suspend Current ECN
![Page 16: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/16.jpg)
Sourcing VBUS
“No device shall supply (source) current on VBUS at its upstream facing port at any time.”
USB 2.0 section 7.2.1http://forum.pololu.com/viewtopic.php?f=3&t=3083
Arduino Uno does it though
![Page 17: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/17.jpg)
Inrush current limiting
USB 2.0 section 7.2.4.1; Device Capacitance ECN
VBUS (5 V)
GND (0 V)
USB Host USB Device
+++
- - -
+++
- - -
VBUS
GND
1 µF < CRPB
< 10 µF120 µF < CHPB
![Page 18: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/18.jpg)
USB data lines
![Page 19: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/19.jpg)
USB resistors
USB 2.0 figure 7-20; Pull-up/pull-down resistors ECN
● D+ pull-up should be controllable so you can disconnect from the bus.● D+ pull-up should only be powered when VBUS is present.● D+ and D- use 0 V to 3.3 V signalling levels.
![Page 20: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/20.jpg)
Signalling levels
● J: D+ high, D- low: default● K: D+ low, D- high● SE0: both low: signals reset or end of packet● SE1: both high: not used
USB 2.0 section 7.1.7.1
![Page 21: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/21.jpg)
Packet boundaries
● Start of packet:Data lines switch from idle (J) to K.
● End of packet:SE0 for 2 bit times, J for 1 bit time.
USB 2.0 section 7.1.7.1
![Page 22: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/22.jpg)
Sync pattern
Every packet starts with KJKJKJKK:
D+
USB 2.0 section 7.1.1.10
![Page 23: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/23.jpg)
NRZI: Non Return to Zero Invert
USB 2.0 section 7.1.8
● Changing voltage level represents a 0● Same voltage level represents a 1
K J K J K J K K J J J K K J J K J K K J K K K J SE0 -------- sync --------- 0 1 1 0 1 0 1 0 0 0 1 0 0 1 1 0
![Page 24: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/24.jpg)
Bit stuffing
A zero is inserted after every six consecutive ones in the data stream, to force a transition.
USB 2.0 section 7.1.9
00101111110110110
![Page 25: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/25.jpg)
That's how packets work.Now we can just think of each
packet as a sequence of 0s and 1s.
Start, 0111011010111010101110000, End
![Page 26: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/26.jpg)
Packet identifier (PID)
Every packet starts with a 4-bit PID and its inverse.
USB 2.0 section 8.3.1
![Page 27: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/27.jpg)
PID types (the important ones)
● 0001: OUT token● 1001: IN token● 0101: SOF token● 1101: SETUP token● 0011: DATA0● 1011: DATA1● 0010: ACK handshake● 1010: NAK handshake● 1110: STALL handshake
USB 2.0 section 8.3.1
![Page 28: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/28.jpg)
Packet types and their fields
● OUT, address, endpoint, CRC5● IN, address, endpoint, CRC5● SOF, frame number, CRC5● SETUP, address, endpoint, CRC5● DATA0, data, CRC16● DATA1, data, CRC16● ACK● NAK● STALL
address: 7-bitendpoint: 4-bitdata: 0 to 1024 bytes
![Page 29: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/29.jpg)
Packets are combined to formtransactions.
![Page 30: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/30.jpg)
OUT transaction
● Transfers data out from the host to the device
1) Host: OUT (address, endpoint)2) Host: DATA0 or DATA1 packet3) Device: ACK, NAK, STALL
![Page 31: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/31.jpg)
IN transaction
● Transfers data in to the host from the device
1) Host: IN (address, endpoint)2) Device: DATA0, DATA1, or NAK packet3) Host: ACK
![Page 32: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/32.jpg)
USB 2.0 figure 8-38
![Page 33: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/33.jpg)
Transaction considerations
● Host initiates all transactions● Device must respond very fast● Device responses are usually queued up
ahead of time an then handled entirely by hardware
● Can't easily make wireless USB
![Page 34: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/34.jpg)
Data toggle and error handling
● We already have ACK packets, but what happens if the ACK is lost?
● The sender must resend packet until ACKed.● Receiver must be able to detect duplicate
packets.● Solution: data toggle bit included with every
DATA packet in the PID (DATA0 or DATA1)
USB 2.0 section 8.6
![Page 35: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/35.jpg)
Endpoint types
● Interrupt: guaranteed latency● Bulk: best effort● Control: requests and responses● Isochronous: streaming, no error handling
![Page 36: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/36.jpg)
EOP
![Page 37: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/37.jpg)
USB 2.0 page 1
![Page 38: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/38.jpg)
Address and endpoint fields
● Only present for OUT, IN, and SETUP packets● 7-bit device address
– Devices use address 0 after being reset (D+ and D- low for a while), and then the host assigns another address.
● 4-bit endpoint number
USB 2.0 section 8.3.2.1
![Page 39: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/39.jpg)
Data field
● Only present for DATA0 and DATA1 packets.● Integral number of bytes from 0 to 1024
USB 2.0 section 8.3.4
![Page 40: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/40.jpg)
Cyclic Redundancy Checks (CRCs)
● 5-bit CRC for IN/OUT/SETUP packets.● 16-bit CRC for DATA0/DATA1 packets.● Packets with failed CRCs must be ignored.
USB 2.0 section 8.3.5
![Page 41: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/41.jpg)
USBPart 1: Wires, packets, transactions
David Grayson2015-07-23
![Page 42: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/42.jpg)
Which USB are we talking about?
● Full speed (12 Mbps)● Universal Serial Bus Specification
Revision 2.0, April 27, 2000● 650 page document● Engineering Change Notices (ECNs)
![Page 43: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/43.jpg)
Types of USB
● Low Speed: 1.5 Mbps● Full Speed: 12 Mbps● High Speed: 480 Mbps● SuperSpeed: up to 5000 Mbps● SuperSpeed+: up to 10000 Mbps
![Page 44: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/44.jpg)
Bus topology
● One host– Detects devices, initiate communication
● Multiple devices– Provides one or “functions” to the host
![Page 45: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/45.jpg)
USB 2.0 section 4.1.1
![Page 46: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/46.jpg)
Topology is enforced by connectors
A plugB plug
B receptacle
A receptacle
http://uk.farnell.com/multicomp/mc32593/usb-2-0-type-a-recetpacle-th/dp/1696534
![Page 47: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/47.jpg)
USB 2.0 section 6.4.4
Prohibited cable assemblies
“USB is optimized for ease of use. The expectation is that if the device can be plugged in, it will work.”
![Page 48: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/48.jpg)
Prohibited cable assembly:Extension cables assembly
USB 2.0 section 6.4.4http://www.amazon.com/Belkin-USB-Extension-Cable-10-Feet/dp/B00001ZWXA
![Page 49: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/49.jpg)
Prohibited cable assembly:Cable that violates USB topology
rules
USB 2.0 section 6.4.4 http://www.showmecables.com
But USB On-the-go (OTG) is fine.
![Page 50: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/50.jpg)
Prohibited cable assembly:Standard detachable cables for
low-speed devices ● “Using a long high-/full-speed cable exceeds
the capacitive load of low-speed.”
https://www.sparkfun.com/products/9825https://learn.adafruit.com/introducing-trinket/introduction
![Page 51: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/51.jpg)
● Chapter 6 has more mechanical specifications● My favorite part:
USB 2.0 section 6.7
7.9 lbs
2.2 lbs
![Page 52: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/52.jpg)
That's enough mechanical stuff.Let's talk about the electronics….
![Page 53: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/53.jpg)
USB wires
USB 2.0 section 6.3
![Page 54: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/54.jpg)
Power distribution: Voltage
USB 2.0 section 7.2
Devices typically get 5.0 V but it could be as low as 4.35 V.
![Page 55: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/55.jpg)
Current limits
● “Unit load” is defined to be 100 mA● Low power device: 1 unit load (100 mA)● High power device: up to 5 unit loads (500 mA)● Devices cannot draw more than 1 unit load until
the device is configured by the host.● (Later USB specifications allow for a lot more
current.)● Suspend mode: 2.5 mA
USB 2.0 section 7.2.1, Suspend Current ECN
![Page 56: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/56.jpg)
Sourcing VBUS
“No device shall supply (source) current on VBUS at its upstream facing port at any time.”
USB 2.0 section 7.2.1http://forum.pololu.com/viewtopic.php?f=3&t=3083
Arduino Uno does it though
![Page 57: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/57.jpg)
Inrush current limiting
USB 2.0 section 7.2.4.1; Device Capacitance ECN
VBUS (5 V)
GND (0 V)
USB Host USB Device
+++
- - -
+++
- - -
VBUS
GND
1 µF < CRPB
< 10 µF120 µF < CHPB
![Page 58: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/58.jpg)
USB data lines
![Page 59: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/59.jpg)
USB resistors
USB 2.0 figure 7-20; Pull-up/pull-down resistors ECN
● D+ pull-up should be controllable so you can disconnect from the bus.● D+ pull-up should only be powered when VBUS is present.● D+ and D- use 0 V to 3.3 V signalling levels.
![Page 60: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/60.jpg)
Signalling levels
● J: D+ high, D- low: default● K: D+ low, D- high● SE0: both low: signals reset or end of packet● SE1: both high: not used
USB 2.0 section 7.1.7.1
![Page 61: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/61.jpg)
Packet boundaries
● Start of packet:Data lines switch from idle (J) to K.
● End of packet:SE0 for 2 bit times, J for 1 bit time.
USB 2.0 section 7.1.7.1
![Page 62: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/62.jpg)
Sync pattern
Every packet starts with KJKJKJKK:
D+
USB 2.0 section 7.1.1.10
![Page 63: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/63.jpg)
NRZI: Non Return to Zero Invert
USB 2.0 section 7.1.8
● Changing voltage level represents a 0● Same voltage level represents a 1
K J K J K J K K J J J K K J J K J K K J K K K J SE0 -------- sync --------- 0 1 1 0 1 0 1 0 0 0 1 0 0 1 1 0
![Page 64: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/64.jpg)
Bit stuffing
A zero is inserted after every six consecutive ones in the data stream, to force a transition.
USB 2.0 section 7.1.9
00101111110110110
![Page 65: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/65.jpg)
That's how packets work.Now we can just think of each
packet as a sequence of 0s and 1s.
Start, 0111011010111010101110000, End
![Page 66: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/66.jpg)
Packet identifier (PID)
Every packet starts with a 4-bit PID and its inverse.
USB 2.0 section 8.3.1
![Page 67: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/67.jpg)
PID types (the important ones)
● 0001: OUT token● 1001: IN token● 0101: SOF token● 1101: SETUP token● 0011: DATA0● 1011: DATA1● 0010: ACK handshake● 1010: NAK handshake● 1110: STALL handshake
USB 2.0 section 8.3.1
![Page 68: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/68.jpg)
Packet types and their fields
● OUT, address, endpoint, CRC5● IN, address, endpoint, CRC5● SOF, frame number, CRC5● SETUP, address, endpoint, CRC5● DATA0, data, CRC16● DATA1, data, CRC16● ACK● NAK● STALL
address: 7-bitendpoint: 4-bitdata: 0 to 1024 bytes
![Page 69: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/69.jpg)
Packets are combined to formtransactions.
![Page 70: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/70.jpg)
OUT transaction
● Transfers data out from the host to the device
1) Host: OUT (address, endpoint)2) Host: DATA0 or DATA1 packet3) Device: ACK, NAK, STALL
![Page 71: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/71.jpg)
IN transaction
● Transfers data in to the host from the device
1) Host: IN (address, endpoint)2) Device: DATA0, DATA1, or NAK packet3) Host: ACK
![Page 72: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/72.jpg)
USB 2.0 figure 8-38
![Page 73: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/73.jpg)
Transaction considerations
● Host initiates all transactions● Device must respond very fast● Device responses are usually queued up
ahead of time an then handled entirely by hardware
● Can't easily make wireless USB
![Page 74: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/74.jpg)
Data toggle and error handling
● We already have ACK packets, but what happens if the ACK is lost?
● The sender must resend packet until ACKed.● Receiver must be able to detect duplicate
packets.● Solution: data toggle bit included with every
DATA packet in the PID (DATA0 or DATA1)
USB 2.0 section 8.6
![Page 75: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/75.jpg)
Endpoint types
● Interrupt: guaranteed latency● Bulk: best effort● Control: requests and responses● Isochronous: streaming, no error handling
![Page 76: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/76.jpg)
EOP
![Page 77: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/77.jpg)
USB 2.0 page 1
![Page 78: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/78.jpg)
Address and endpoint fields
● Only present for OUT, IN, and SETUP packets● 7-bit device address
– Devices use address 0 after being reset (D+ and D- low for a while), and then the host assigns another address.
● 4-bit endpoint number
USB 2.0 section 8.3.2.1
![Page 79: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/79.jpg)
Data field
● Only present for DATA0 and DATA1 packets.● Integral number of bytes from 0 to 1024
USB 2.0 section 8.3.4
![Page 80: USB Part 1: Wires, packets, transactions2015/07/23 · Arduino Uno does it though Inrush current limiting USB 2.0 section 7.2.4.1; Device Capacitance ECN VBUS (5 V) GND (0 V) USB](https://reader033.vdocuments.us/reader033/viewer/2022042405/5f1e07050b789d01a146f5c6/html5/thumbnails/80.jpg)
Cyclic Redundancy Checks (CRCs)
● 5-bit CRC for IN/OUT/SETUP packets.● 16-bit CRC for DATA0/DATA1 packets.● Packets with failed CRCs must be ignored.
USB 2.0 section 8.3.5