7-1 Lecture 7 Agenda Isochronous Transfers Using HID with Visual BASIC Resources Demo USB Diagnostic...
-
Upload
margaret-cooper -
Category
Documents
-
view
215 -
download
1
Transcript of 7-1 Lecture 7 Agenda Isochronous Transfers Using HID with Visual BASIC Resources Demo USB Diagnostic...
7-1
Lecture 7 Agenda
Isochronous TransfersUsing HID with Visual BASIC Resources Demo
USB Diagnostic Tools USBCheck HIDCheck
USB 2.0
7-2
Isochronous Transfers
7-3
Isochronous Transfers (1 of 3)
OUTnDATA Register
USBOUTData
USBIN
Data
8051 FIFO
USB FIFO
8051 FIFO
USB FIFO
INnDATA Register
SOF
SOF(n=8-15)
(n=8-15)
7-4
TRM Chapter 8 Set the ISO endpoint valid bits
INISOVAL (0x7FE0), OUTISOVAL (0x7FE1) Set up the FIFO sizes
Use OUTnADDR registers These set the starting addresses for the ISO FIFOS Size is allocated in increments of 16 bytes All ISO endpoints share 1024 bytes of FIFO memory Start address (SA) register format:
A9 A8 A7 A6 A5 A4 0 0 (0 0) Example1: EP8IN=512, EP8OUT=512
IN8ADDR = 0 OUT8ADDR = 512 = 1000000000, SA=10000000=0x80
Isochronous Transfers (2 of 3)
7-5
ISO data available as FIFO, not RAM 16 FIFO data registers:
OUT8DATA, OUT9DATA, ... OUT15DATAIN8DATA, IN9DATA, ... IN15DATA
One USB interrupt for all ISO endpoints SOF, every millisecond
SOF_ISR should read/write ISO fifo data Set DPTR to the endpoint, then execute
multiple ‘movx’ instructions Don’t need to increment DPTR each access
Example code on TRM page 8-8 (Fig 8-6)
Isochronous Transfers (3 of 3)
7-6
Using HID with Visual BASIC
7-7
Read Axelson Chapter 16 “Human Interface Devices: Host Application Example Shows code for both VB and VC++
First edition of the book had a CD, Second edition does not Go to lvr.com, download ‘usbhidio’
Unpack it VisualBasic folder has VB Project (usbhidio.vbp)
In project ‘Modules’ folder: ApiDeclarations.bas Contains VB declarations to allow VB to make C-style API
calls VB application code in ‘frmMain.frm’ Change VID and PID values to 0547/7450:
'Set these to match the values in the device's firmware and INF file.Const MyVendorID = &H547Const MyProductID = &H7450
VB-HID Development Stepshost side
7-8
Keil project: gpHID.uv2 fw2HID.c (from last session) gpHID_descriptors.a51
INT-IN and INT-OUT endpoints Report descriptor specifies 2-byte in and out reports
Compile and load the code Start the debugger
First time: you’ll see the “HID Device Found” box Readout should start incrementing
VB-HID Development Stepsdevice side
7-9
Run the VB code It should find the device Then Allows you to send two-byte out reports
First byte is readout increment rate Second byte is decimal point
Shows the results of two-byte input reports First byte is current digit Second byte is pushbutton states
VB-HID Development Stepsboth sides
7-10
My Customizationbased on Jan’s code
7-11
A VB HID Test Control PanelClick
7-12
Sending an OUTPUT ReportThe PC Side
SendBuffer(0) = 0 ‘ The first byte is the Report ID
SendBuffer(1) = 31 - hsRate.Value ' next 2 bytes are data--rate
SendBuffer(2) = dp ' decimal point
NumberOfBytesWritten = 0
Result = WriteFile _
(HidDevice, _
SendBuffer(0), _
CLng(Capabilities.OutputReportByteLength), _
NumberOfBytesWritten, _
0)
7-13
Sending an OUTPUT ReportThe Peripheral Side
if(!(OUT1CS & bmEPBUSY)) // Is there something available?
{
timeconst = OUT1BUF[0]*20; // Output Report Byte 0 is time // const (tenths of sec)
dp = OUT1BUF[1]; // decimal point
OUT1BC = 0; // Re-arm EP1-OUT
IN1BUF[0] = count;
IN1BUF[1] = buttons;
IN1BC = 2; // arm the EP2-IN transfer
}
7-14
Reading an INPUT ReportThe PC Side
Result = ReadFile _
(HidDevice, _
ReadBuffer(0), _
CLng(Capabilities.InputReportByteLength), _
NumberOfBytesRead, _
0)
tb7SEG = Hex$(ReadBuffer(1)) ' put first byte value into text box (7-seg value)
readval = ReadBuffer(2) ' get button states
7-15
Reading an INPUT ReportThe Peripheral Side
if(!(OUT1CS & bmEPBUSY)) // Is there something available?
{
timeconst = OUT1BUF[0]*20; // Output Report Byte 0 is time // const (tenths of sec)
dp = OUT1BUF[1]; // decimal point
OUT1BC = 0; // Re-arm EP1-OUT
IN1BUF[0] = count;
IN1BUF[1] = buttons;
IN1BC = 2; // arm the EP2-IN transfer
}
7-16
USB Diagnostic Tools
7-17
USB Diagnostic Tools
USBCheck Tests for Chapter 9 Compliance Tricky to use
HIDView Tests HID devices Tricky to use
7-18
USBCheck Versions
OSUSBCheck
VersionUSBDiag.sys
VersionController
Win98 Gold 2.9 4.10.1706 UHCI
Win98 SE 3.2 5.00.1868.1 UHCI
Win98 SE 3.2 5.10.1868.1 OHCI
7-19
USBCheckOrder is critical
Start USBCheck
Start up your ReNumerating 8051 code
Exit program, then physically disconnect your device
7-20
USBCheck
Don’t start HIDView from here. Instead, quit USBCheck, unplug your device, then launch HIDView as a separate program.
7-21
HIDView
7-22
HIDViewReady to roll
7-23
USB 2.0
7-24
USB 2.0 in a Nutshell Runs 40X faster than USB 1.1
Low speed: 1.5Mb/s Full speed: 12Mb/s High speed: 480Mb/s
Fully supports existing USB devices Forward compatible—plug existing 1.1 devices
into new 2.0 hosts Backward compatible—plug new 2.0 devices
into existing 1.1 hosts Uses the same cables as USB 1.1
7-25
USB 2.0 Hub Magic
PCUSB 2.0 USB 2.0
1.1 HubUSB USB USB USB
FSDevice
FSDevice
12 MBits/sec shared between
devices
2.0 HubUSB USB USB USB
FSDevice
FSDevice
12 MBits/sec per device
HSDevice
7-26
USB 2.0 Specification
Revision 2.0, April 27, 2000 622 pages Full spec available at:
www.usb.org/developers/docs.html
7-27
Cable Magic USB 1.1
D+ / D–
45
45
3.3V
7-28
Cable Magic USB 2.0
D+ / D–
17 ma
400 mV
45
45
7-29
SOF
327
SOF
328
1 msec
ISO (~1000)
BU
LK
(64
)
USB 1.1 BandwidthC
TL
(64
)
7-30
SOF
327
SOF
328
USB 2.0 Bandwidth
SOF
327
SOF
327
SOF
327
SOF
327
SOF
327
SOF
327
SOF
327
125 usec
125 usec
125 usec
125 usec
125 usec
125 usec
125 usec
125 usec
1 msec
SOF
327
SOF
327
1024
SOF
327
SOF
327
512
641024 1024 512 512 ISOINT
BU
LK512 512 512 512 512 512 512 512 512 512 512
CT
L
64
7-31
Packet Sizes
Control
Bulk
Interrupt
Isochronous
8, 16, 32, 64
8, 16, 32, 64
1–64
1023
64
512
1024
1024
USB 1.1 USB 2.0
Transfer Type Packet Size
7-32
USB 2.013 Bulk packets per microframe max13 * 512 * 8 * 1000 = 53 MB/s
Bandwidth Example:ATA Hard Drive
7200 RPM, 512 Kbyte Internal Buffer
Internal data transfer rate: 40MB/s Avg. sustained transfer rate: 15 MB/s Channel rate: 66.6MB/s
7-33
USBHost
Buffer
Head
40
Disk Drive
USB 2.0Controller
USB 6020–50 IF
15 Sustained
Bandwidth Analysis: USB Hard Drive
7-34
Bandwidth Conclusions
Both sides, USB and Interface, must support high bandwidth
USB Large endpoint buffers At least double buffering
Interface Internal processor should not touch 480 Mbit/sec
data. Use the CPU for USB housekeeping & I/O. Optimize the data channel using specialized logic.
Fast data transfers require fast control logic. Interface logic should be programmable ATA, EPP, etc.
7-35
16Low level protocolLow level protocolCRC, PID encode-CRC, PID encode-
decode, chirp decode, chirp Deliver WORDS Deliver WORDS
TokenTokenProcessorProcessorEP0, Ping,EP0, Ping, ACK/NAK/ ACK/NAK/
STALL/STALL/NYETNYET
"Chapter 9""Chapter 9"
Outside InterfaceOutside Interface
High speed logicHigh speed logicclock extractionclock extraction
serialize/serialize/ deserialize deserialize
bit stuffbit stuffNRZINRZI
SYNC,SYNC,EOPEOP
16
16 EndpointsEndpointsEndpoint FIFOSEndpoint FIFOS& control logic& control logic
16
CPUCPU48 MHz48 MHz 8051 8051
Program & Program & Data RAMData RAM
Dow
nloa
d C
ode
Dow
nloa
d C
ode
Dat
a C
han
nel
GPIF
Single-Chip Solution
7-36
USB BW: Endpoint Buffers
512512
512512
512512
512512
EP2
EP4
512512
512512
512512
512512
EP2
512512
512512
512512
512512EP6
EP8
512512
512512
512512
512512
EP6
512512
512512
512512
512512
EP2
512512
512512EP6
10241024
10241024
EP2
10241024
10241024
EP6
10241024
10241024
EP2
10241024
10241024
10241024
EP2
10241024
10241024
512512
512512EP8
EP0 IN&OUTEP0 IN&OUTEP1 INEP1 IN
EP1 OUTEP1 OUT 646464646464
646464646464
646464646464
646464646464
646464646464
646464646464
512512
512512EP8
7-37
Endpoint
FIFOSMicroprocessorUSB
OutsideWorld
(a) Low to Medium Speed
Data Transfer Speed Evolution
7-38
Data Transfer Speed Evolution
Endpoint
FIFOS
InterfaceFIFODMAUSB
OutsideWorld
(b) Faster
Microprocessor
RAM/FIFO
7-39
Data Transfer Speed Evolution
Endpoint
FIFOSUSB
OutsideWorld
(c) Fastest
Microprocessor
RAM/FIFO
7-40
Making the High Bandwidth Data Available to the Outside World
Don’t let the CPU be a bottleneck Use fast logic to do the transfers
Some type of DMA is essential Even better--”Zero time” DMA
transfers with programmable control signals
GPIF = General-Purpose Interface
7-41
Quantum FIFO
256x16
256x16
256x16
256x16
USB
256x16
I/O
256x16
256x16
256x16
1 clock
7-42
Quantum FIFO
256x16
256x16
256x16
USB
256x16
I/O
256x16
256x16
256x16
256x16
7-43
Quantum FIFO
256x16
256x16
256x16
USB
256x16
I/O
256x16
256x16
256x16
1 clock
256x16
7-44
Quantum FIFO
256x16
256x16
256x16
USB
256x16
I/O
256x16
256x16
256x16
256x16
7-45
Quantum FIFO
256x16
256x16
256x16
USB
256x16
I/O
256x16
256x16
256x16
256x16
8051