MCU User Forum
  USB
  USB for Dummies (one dummy, anyway)

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   USB for Dummies (one dummy, anyway)
rmac
Member
posted September 25, 2006 10:44 AM     Click Here to See the Profile for rmac   Click Here to Email rmac     Edit/Delete Message
I am looking for a crash course (something I can do in a few hours) on how USB works from the device's (not the host's) point of view. I fully realize that I'm not going to really understand it in such a short time, but I would at least like to be able to string together sentences that include terms like "enumeration" and "endpoint" and "device class", without sounding like a total bozo.

Can anyone point to a Silicon Labs app note or perhaps a favorite web based tutorial that would get me started? I'm currently plowing through the 100s of hits that I get from a Google search, but it's slow going trying to weed out the junk.

Thanks,

-- Russ

IP: Logged

Curt
Member
posted September 25, 2006 01:53 PM     Click Here to See the Profile for Curt   Click Here to Email Curt     Edit/Delete Message
The Intel University Press did a book called
_USB Design By Example_ by John Hyde that you can surely borrow through your library
(interlibrary loan maybe). I thought it did a good job of introducing the subject in a "hands-on" kind of way. Surely out of date (1999 pub.)

IP: Logged

Tsuneo
Member
posted September 25, 2006 02:08 PM     Click Here to See the Profile for Tsuneo   Click Here to Email Tsuneo     Edit/Delete Message
Nowadays, most of manufacturers provide libraries or examples for USB engine on their MCUs. The most complicated part of USB coding, enumeration and USB class support are already built-in these materials. Then, what you must learn first is how to modify it, and why this modification is required.

1. VID/PID (Vendor ID/ Product ID): (in device descriptor)
must be unique to a product. INF file matches VID/PID from the device and device driver on the host.

2. Serial number (in string descriptor)
must be unique to each device. Windows holds the device record according to serial number.

3. USB transfer type: bulk, interrupt and isochronous (ignore control transfer at first)
To select a transfer type fits to your requirement, examine the difference of these transfer type.

in full speed     bulk        interrupt     isochronous
Max packet size 64 64 1023
Max packets/msec 19 1 1
Error retry yes yes no
transfer speed best effort guaranteed guaranteed

See this link for detail.
USB in NutShell: http://www.beyondlogic.org/usbnutshell/usb4.htm

To send/receive greater size of data, you must split the data into packet on the firmware.
It is similar to UART. To send greater size of data, UART split it into a byte.
USB split it into packets instead of byte.

4. Difference of OUT (PC -> device) and IN (device -> PC) transfer

Handling of transfer is also similar to UART RX/TX on the firmware.
To start USB IN transfer, load a packet to the buffer (USB FIFO) first, like TX on UART.
USB IN interrupt is evoked when the buffer is empty, also like TX on UART.
However, USB IN doesn't start until host PC polls the device,
though the UART TX starts just after the firmware loads data to buffer.
USB OUT transfer is much similar to UART RX.

USB OUT (PC -> device) - UART RX
- host PC send a packet to device
- the MCU USB engine stores the packet on a buffer (USB FIFO)
- the firmware knows the arrival of the packet by interrupt or polling
- the firmware read out the packet from the USB FIFO

USB IN (device -> PC) - UART TX
- the firmware stores a packet to USB FIFO
- the USB engine waits until the host PC polls the device
- the USB engine sends the packet to the host PC
- the firmware knows the USB FIFO is empty by interrupt or polling
- the firmware stores next packet to USB FIFO


The essence is that's all. USB is so simple as long as you are working on established materials. Buy a kit and fiddle it.

(But once you step in maniac region, like I and Patryk in this topic, you'll see hell of detail. Keep out from this region, if you want to sleep well every day )

Tsuneo

[This message has been edited by Tsuneo (edited September 25, 2006).]

IP: Logged

rmac
Member
posted September 25, 2006 04:48 PM     Click Here to See the Profile for rmac   Click Here to Email rmac     Edit/Delete Message
Tsuneo,

Thanks very much for your informative post. (Thanks also for
spending so much time helping _everybody_ here.) You make it sound easy. I think I can do it.

-- Russ

[This message has been edited by rmac (edited September 25, 2006).]

IP: Logged

Tsuneo
Member
posted September 26, 2006 12:02 AM     Click Here to See the Profile for Tsuneo   Click Here to Email Tsuneo     Edit/Delete Message
a) How to get unique VID/PID

- Several manufacturers distribute unique PID under their VID. SiLabs also.
MCU Knowledge Base 87271 "Obtaining a Unique PID"

- You can buy a range of PID
VOTI: http://www.voti.nl/shop/catalog.html?USB-PID-10
Mecanique: http://www.mecanique.co.uk/products/usb/pid.html

- To get VID formally from USB.org
1. Become a member of the USB-IF for an annual membership fee of US$4000.
2. Logo licensee for US$2000 for a 2 year term.
3. Pay a one-time fee of US$2000
http://www.usb.org/developers/vendor/


b) How to assign unique serial number to each device

Automatically assigning Serial Numbers
Reporting a Serial Number

Tsuneo

IP: Logged

rmac
Member
posted September 26, 2006 09:58 AM     Click Here to See the Profile for rmac   Click Here to Email rmac     Edit/Delete Message
Tsuneo,

Thanks for the extra info.

-- Russ

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | MCU User Forum

Have you seen our MCU Knowledge Base?


Ultimate Bulletin Board 5.47b

Site Guide Privacy Legal