Introduction To Microchip USB Solutions
Introduction To Microchip USB Solutions
Introduction to
Microchip USB Solutions
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 1
Objectives
When you finish this class you will
be able to:
Describe the basics of USB, and how
apply them in an embedded application
Identify Microchip’s USB MCUs,
development boards, and USB software
frameworks relevant to your project
Chose the right USB MASTERs classes
you need to attend
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 2
Agenda
USB Fundamentals
Microchip USB solutions
Design considerations
How to get started
Summary
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 3
Universal Serial Bus
Extend the functionality of
your computer!
Data Analysis,
Data Logging,
Firmware Updates,
Diagnostics,
Embedded Applications!
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 4
Agenda
USB Fundamentals
Microchip USB solutions
Design considerations
How to get started
Summary
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 5
USB Basics
USB is a “Single Master + Multiple Slaves” polled bus
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 7
Typical MCU Requirements for
Host
Typically Host is a PC
USB 3.0 Host Controller, running at Full
Speed (12 Mbps) or High Speed (480
Mbps) or Super Speed (5 Gbps)
High throughput 32/64 bit CPU running a
Operating System like Windows®
USB Drivers identifying and enumerating
USB Devices
Automatic update of USB drivers
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 8
Host in Embedded Design
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 9
Embedded Host
Embedded Host connects to a fixed number of USB
Peripheral Devices – USB Drivers fixed in firmware
Advantage: Smaller, less complex embedded firmware
Example: Remote Temperature Data Logger
Download data to USB Flash Drive
Not connected directly to PC Host but …
You can exchange data with PC Host using the Flash Drive
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 10
Typical Requirements for
Embedded Host
Peripherals to service real world I/O:
A/D converters, Comparators, etc.
Serial Interfaces like SPI, I2C™, UART
PWMs, Timers and I/O lines
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 12
USB Peripheral Device
Responds to Host, cannot initiate transactions
Requires drivers to be recognized by the Host
Hardware/Firmware to respond to Host
Microchip’s PIC® MCUs are used in USB
Peripheral Devices
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 13
Typical MCU Requirements
for Peripheral Device
Peripherals to service real world I/O:
A/D converters, Comparators, etc.
Serial Interfaces like SPI, I2C™, UART
PWMs, Timers and I/O lines
Full Speed (12 Mbps) USB 2.0 Transceiver with
data input/output buffers
Throughput to service Full speed USB requests
USB Device and peripheral interface Firmware
All USB PIC® MCUs are designed for USB
Peripheral Device applications
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 14
USB On-The-Go (OTG)
USB On-The-Go (OTG) allows Application to operate as
Host or Device:
PDA (Device) connected to PC (Host)
PDA (Host) connected to Thumb drive (Device)
PDA connected to PDA, host and device roles can switch
(OTG mode)
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 15
Typical Requirements for OTG
Devices
Peripherals to service real world I/O:
A/D converters, Comparators, etc.
Serial Interfaces like SPI, I2C™, UART
PWMs, Timers and I/O lines
Full Speed (12 Mbps) USB 2.0 OTG Transceiver
with data input/output buffers
High throughput 16/32-bit MCU
Host Software Drivers to identify and
enumerate USB Peripheral Devices
Device Drivers when connected to Host/OTG
Microchip’s 16 and 32-bit USB PIC® MCUs are
designed for USB OTG applications
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 16
Other USB Device Types
Hub
Repeats traffic (both directions), manages power
Compound Device
Contains a hub and 1 or more peripherals
Host treats hub and peripheral function separately (each
has its own address)
i.e. USB keyboard with 1-port hub
Composite Device
Has multiple interfaces active at the same time
Host loads a driver for each interface
i.e. video camera (both audio & video interfaces active)
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 17
MCP2200: USB to UART
Serial Converter
Enables USB connectivity in applications with
UART
Pre-programmed USB stack
Easy to configure GPIO USB LEDs
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 20
DRD Example Circuit
PIC24F or PIC32MX 5v Embedded
USB device Host
PPTC 150μF
3.3v Receptacle
VUSB
VBUS
D-
1μF
2KΩ D+
A/D GND
2KΩ
Peripheral
VBUS Receptacle
Input 1μF 150KΩ
VBUS
D-
D- D+
D+ GND
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 21
Physical Interface
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 22
Standard Connectors
“A”
USB Host
Full or Embedded
μB μB
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 23
Standard Connectors
“micro-AB”
OTG
Host μA
“micro-AB”
OTG
Host μA
“B” “mini-B” “micro-B”
USB USB USB
Device Device Device
“micro-AB”
OTG
Device μB
μB
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 24
Physical Bus Topology
Host (Tier 1)
USB Host Controller
& Root Hub
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 25
Logical Bus Topology
Not a tiered-star!
Host software communicates to each
“logical” device as if it were directly
connected to the root hub
Host
Logical
Device Logical
Device
Logical Logical
Device Device Logical
Device
Logical
Device
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 26
USB Device Framework
- Software View of Hardware -
Host System Peripheral Device
Function Layer
Pipe Bundle
Client Function
Function Layer
Client Interface Function
Software
Client Function
Software
Software
Buffers Interface-specific
USB Device
USB Device
Layer
Layer
Bus Interface
Bus Interface
Layer
Layer
Data Bucket
USB PIC® MCU
Configuration
Interface
Analog/Digital I/O
IN (Endpoint x)
USB Device-Specific Pipe(s) HID TX/RX Functions
(Human Interface Device) OUT (Endpoint x) (MCHPFSUSB FW)
USB Transaction
Token Packet
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 30
IN Transaction ACK
USB Transaction
IN Token Packet
Data Packet
Handshake Packet
Acknowledge - ACK
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 31
IN Transaction NAK
USB Transaction
IN Token Packet
Handshake Packet
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 32
OUT Transaction ACK
USB Transaction
Data Packet
Handshake Packet
Acknowledge - ACK
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 33
OUT Transaction NAK
USB Transaction
Data Packet
Handshake Packet
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 34
Demo
- Capturing a Transaction -
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 36
Transfer: A Group of Related
Transactions
MPUSBWrite(EP7, Pointer, Size = 129, Timeout)
Transfer
Key:
Transaction 1
64 Byte Payload OUT Token Packet
Data Packet
Transaction 2
64 Byte Payload ACK Handshake Packet
Transaction 3
1 Byte Payload
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 37
Data Transfer Types
Traffic to other
Endpoints or Idle Transactions
64 64 1
Frame
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 39
Bulk Transfer Example
MPUSBWrite(EP7, Pointer, Size = 129, Timeout)
Transactions only
occur if no higher
priority traffic
Frame
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 40
Theoretical Maximum Transfer
Rate Per Endpoint
1400
1216
1200
1023
1000 832
800
KByte/s
600 Low
400 Full
200 64
24 0.8
0
Control Interrupt Bulk Iso
Transfer Type
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 41
Quiz!
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 42
USB Device Classes
Floppy
Data Glove Drive
Ethernet
Adapter
Mouse
External
Hard Drive
PICkit™ 3
Starter Kit Modem
Mass Storage Device
Joystick Class (MSD)
Communication Device
Class (CDC) MPLAB®
Keyboard REAL ICE™
in-circuit emulator
Custom Class
(Vendor Class)
Human Interface Device Class
(HID)
Many more classes….
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 43
The Enumeration Process
POWERED
Power Bus
(self/bus) reset
ATTACHED DEFAULT
DETACHED ADDRESS
Get
Descriptors
CONFIGURED
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 44
Descriptors
String 0 Device
String 1
To other Configurations if any
String N Configuration 1
To other
Interfaces if any
Interface 0 Interface 1
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 45
Descriptors - Example
USB 2.0, VID = 0x04D8,
Manu. String Device PID = 0x0007, Num. Configurations,
Strings?
Microchip
Configuration #1: Bus-Powered,
Configuration 1 Remote Wakeup, 500mA, Num.
Prod. String Interfaces
PICDEMTM USB
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 46
Demo
- Viewing Descriptor Information -
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 47
VID & PID
Vendor ID (VID): 16-bit number
Required to market your product
http://www.usb.org/developers/vendor
USD $2,000
Technical & Legal trouble if not using an
approved VID
Product ID (PID): 16-bit number
Microchip’s Sub-licensing Program
Every USB Device product line is required to have
a unique combination of VID and PID
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 48
USB Compliance
Compliance Testing
Must pass to use USB logo
Test fee: USD ~$1,500
Tests device for conformance to USB Framework
and Class standard control requests
USB Protocol Analyzer
“USBCV” USB Command Verifier
www.usb.org/developers/tools
Electrical Signal Quality
Power Management
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 49
Compliance Testing
For USB Compliance Testing:
Download appropriate checklist:
http://www.usb.org/developers/compliance/check_list/peripheral_checklist.pdf
http://www.usb.org/developers/compliance/check_list/compchk_otgeh2_0_v1.0_-_fill-in.pdf
Use certified USB receptacle and cable for testing
Know the TID (Test ID) of your components
Find USB PIC® MCUs TID number on www.microchip.com/usb
For USB Compliance certification:
Independent Test Labs (see www.usb.org for a list)
You need to provide them a compiled Checklist with your device
USB Fundamentals
Microchip USB solutions
Design considerations
How to get started
Summary
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 51
Scalable USB
PIC® MCU Portfolio
PIC24F/PIC24E/dsPIC33E
Low Power, GPU, DSP Engine
Up to 70 MIPS
28- to 144-Pin Packages
Up to 512 KB Flash
Up to 96KB RAM
USB 2.0 Device, Embedded Host, OTG
PIC16F1/PIC18F
Small, Low Power, Low Cost 32-bit
Up to 16 MIPS
14- to 80-Pin Packages 16-bit
Up to 128KB Flash
Up to 4KB RAM 8-bit
USB 2.0 Device Support
Migration
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 52
Microchip Application
Libraries
Download from www.microchip.com/MLA
Contains different stacks (USB, TCP/IP,
Graphics, mTouch™ Sensing Solution,
MDD FS, etc.)
Default installation path:
C:/Microchip Solutions vYYYY-MM-DD/
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 55
MCHPFSUSB Device Class
Demos Available
Joystick
MIDI SDC Data
UPS Logger
Basic
Internal
Microphone Flash
SD Card
Mouse RS-232 Reader
Speaker Mass Storage Device
Digitizer Communication Device Class (MSD)
Class (CDC)
Audio
Keyboard Class
Smart Card CDC+MSD
Blood Reader WinUSB+MSD
Custom Pressure HID+MSD
Thermometer Smart Card
Glucose Class Composite
Human Interface Meter Demos
Device Class (HID) Weighing
WinUSB
Scale high bandwidth
Custom Class
(Vendor Class) More demos in future releases…
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 57
Agenda
USB Fundamentals
Microchip USB solutions
Design considerations
How to get started
Summary
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 58
Considerations When Using
Standard Classes
The Logical USB Device is
pre-defined
Max. bandwidth is fixed
The Device data communication
protocol is defined
For CDC Class the PIC® MCU looks like
a modem, or terminal connected to a
COM port
Main Benefit: Cross-platform use
Custom OS driver is not required!
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 59
CDC – RS-232 Emulation
PIC® Microcontroller PC Computer
CDC Standard Windows Drivers Hyper Terminal
USB Cable
INF File Required
(Supplied in MCHPSUSB)
Design Considerations:
• ~80 KB/s max
• Bulk Transfers
• PC applications can access the device as though it
is connected to a serial COM port
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 60
Human Interface Device (HID)
USB Cable
Design Considerations:
• 64 KB/s max
• Interrupt Transfer Type
• Standard Windows driver
• Custom PC application can access HID data
through Win32 APIs
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 61
Custom Class Driver
PIC® Microcontroller PC Computer
Generic Driver Demo
MCHPUSB.sys MPUSBAPI.dll PDFSUSB.exe
Bootloader
Binary Only Source and Other C++
Binary Binary Only
Examples
USB Cable
Design Considerations:
• ~1,088 KB/s max
• Very flexible (Control, Bulk, Interrupt transfers are
possible)
• Not a standard Windows driver
• PC programming is required
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 62
Agenda
USB Fundamentals
Microchip USB solutions
Design considerations
How to get started
Summary
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 63
USB Classes
USB Device
1641 USB2
USB Human Interface Device (HID) Class
1642 USB3
USB Communication Device Class (CDC)
– Serial Port Emulation
1643 USB4
USB Device - Generic Driver Solutions
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 64
USB Classes
USB Device
1644 USB5
USB Personal Healthcare Device Class
(PHDC)
1645 USB6
Using USB Interface Bridges to Enable
Embedded System Communication with
USB Hosts
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 65
USB Classes
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 66
Microchip Technical
Training
Worldwide Training Centers
and live online classes
In-depth Technical Training
with Hands-on
Ethernet, Motor control,
Graphics, USB, etc.
Local Language Support
Live Onsite training available
www.microchip.com/training
USB classes
COM3101 – Introduction to Full-
Speed USB
COM3201 – Designing a Custom
USB Peripheral
Application
COM3202 – Designing a USB
Embedded Host
Application
© 2012 Microchip Technology Incorporated. All Rights Reserved. Wrap
1640 Up
USB1 Slide 67
Agenda
USB Fundamentals
Microchip USB solutions
Design considerations
How to get started
Summary
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 68
Summary
USB Fundamental
Host is master
Up to 126 devices sharing bandwidth
Microchip USB solutions
USB PIC® MCUs and dsPIC® DCSs
Free USB software & demo codes
Design considerations
USB Classes Pros & Cons
How to get started
USB classes at MASTERs 2012
Microchip Technical Training Live
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 69
Additional Resources
Microchip Design Center
www.microchip.com/USB
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 70
MCHPFSUSB Framework
- Supported Platforms -
Low Pin Count USB Development Kit (PIC18F14K50 Family)
PICDEM™ Full Speed USB (PIC18F4550 family)
MPLAB® Starter Kit for PIC18F MCU (PIC18F46J50 family)
PIC18FxxJ50 FS USB Demo Board (+ HPC Explorer Board)
MPLAB Starter Kit for PIC24F (PIC24FJ256GB106)
PIC24FJ64GB502 Microstick
PIC24FJ256DA210 Development Kit
PIC24F USB PIMs (+ Explorer 16 + USB PICtail™ Plus)
dsPIC33E/PIC24E PIMs (+ Explorer 16 + USB PICtail Plus)
PIC32 USB PIMs (+ Explorer 16 + USB PICtail Plus)
PIC32 USB Starter Board (PIC32MX460F512L family)
PIC32 USB Starter Board II (PIC32MX795F512L family)
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 71
PICDEM™ Full Speed
USB Demo Kit
Contains everything you need to get started quickly
Use with any of the PIC18F4550 family microcontrollers
Available Now
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 72
PIC18FXXJ50 Full-Speed
USB Plug-In Module (PIM)
Contains everything you need to get started quickly
Can be plugged into PICDEM™ HPC Explorer
Board or PICDEM PIC18 Explorer Board
Can be operated as a stand-alone board
Priced from $40.00
Part Numbers
MA180021 - PIC18F87J50 FS USB PIM
MA180024 - PIC18F46J50 FS USB PIM
MA180029 - PIC18F47J53 FS USB PIM
DM183032 - PICDEM PIC18 EXPLORER BOARD
Available Now
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 73
Low Pin Count
USB Development Kit
Contains everything you need to get started quickly
Use with new 20-pin PIC18F USB microcontrollers –
PIC18F13K50, PIC18F14K50
Includes self-directed class and lab material
Quickly implement common USB functions:
RS-232 to Serial
Keyboard/Mouse, etc…
Priced from $39.99
Part Numbers
DM164127
DV164139 (w/PICkit™ 3)
Available Now
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 74
PIC18 Starter Kit
Functions as a USB mouse, joystick or mass storage
device all using the on-board capacitive touch sense
pads
Includes a MicroSD™ memory card, potentiometer,
acceleration sensor, and OLED display
On-board debugger/programming
Completely USB-powered
Demonstrates PIC18 Family
USB communication
Priced from $59.98
Part Numbers
DM180021
Available Now
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 75
16-/32-bit USB Starter Kits
PIC24F Starter Kit
Part #: DM240011
PIC24FJ256GB110
Priced from $59.98
PIC32 USB Starter Kit II
Thumb Drive
Part #: DM320003-2 Debugger
Port
Connection
(Host)
PIC32MX795F512L
Priced from $55.00
On-The-Go Port
Part #: DM320004
PIC32MX795F512L
Priced from $72.00
All Available Now
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 76
16-/32-bit USB Development
Boards
Explorer 16 + USB PICtail™ Plus Daughter
Board + USB PIMs
Part #: MA320003/MA240014
Part #: DM240001
Part #: AC164131
Priced from $214.99
All Available Now
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 77
Thank You!
Please complete the Class Evaluation Form
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 78
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC, KeeLoq, KeeLoq logo, MPLAB,
PIC, PICmicro, PICSTART, PIC32 logo, rfPIC and UNI/O are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL
and The Embedded Control Solutions Company are registered trademarks of Microchip
Technology Incorporated in the U.S.A.
© 2012 Microchip Technology Incorporated. All Rights Reserved. 1640 USB1 Slide 79