Start with one simple test. Get the board recognized by the computer, send a small amount of data, then add the rest of your project. This guide covers Device Library 0.20.0 and Device Configuration Tool 1.17.1.
A device is the PIC board you plug into the computer. The computer is the host. You do not need to learn the whole USB protocol to begin.
First decide what you want the computer to see when you plug in the board. This choice is called the Device class in the tool.

Choose what the computer should see: an input/data device, a serial port, a small drive, or a USB network adapter.
|
Choose |
What appears on the computer |
A typical use |
Application interface |
|
HID, HID data profile |
A HID device |
Exchange small commands, readings and control data with a PC program |
|
|
HID, keyboard/mouse/joystick/consumer profile |
The corresponding input device |
Buttons, keys, movement or media controls |
Fill the profile's report and send it |
|
CDC ACM serial |
A serial/COM port |
Use a terminal or existing serial application |
Send and receive a byte stream |
|
Mass storage |
A drive with 1–8 fixed files |
Present measurements, stored data or settings as files |
Handle file read/write requests |
|
USB browser, RNDIS |
A USB network adapter |
Display values and send commands through a browser |
Publish named values and consume incoming values |
Choose one type for this program. CDC creates a serial port, MSC creates a drive, and browser mode creates a network adapter. Selecting one does not also turn on the others. The tool includes the connections needed by your chosen type.
With HID data, the board uses the standard HID class, but you choose what the sent bytes mean (a vendor-defined report). For example, one byte can be a command and the following bytes can hold a reading. It suits a custom PC program that exchanges small messages with your board.
For a first communication test, choose HID data or CDC ACM serial. For a keyboard or mouse project, choose its actual profile so that the host receives the correct report format.
The USB connection runs at full speed: 12 Mbit/s. Your own data moves more slowly than this bus speed. The chosen class, the computer, packet size and your program all affect the useful transfer rate.
The Framework folder has tested working examples for the USB use cases. Start with the one closest to your project, check its board settings, and get it working before adding your own code. PIC Templates shows the basic interrupt setup for tested devices. Find the supplied examples explains which folder to open.
Use the Device tool: open UsbDeviceConfigTool.exe. The Host and OTG programs are for different jobs and are not used in this guide.
Created with the Personal Edition of HelpNDoc: Easy CHM and documentation editor