Getting Started: Running the “OTG – MCHPUSB – Generic driver demo” demo

Required Hardware: 1

Configuration 1: Explorer 16. 1

Configuring the Hardware: 1

Configuration 1: Explorer 16. 1

Firmware. 3

Running the Demo. 4

Trademarks: 4

## Required Hardware:

To run this project, you will need one of the following sets of hardware:

### Configuration 1: Explorer 16

PIC24FJ256GB110 Plug-In-Module (PIM) (MA240014)

Explorer 16 (DM240001)

USB PICtail™ Plus Daughter Card (AC164131)

## Configuring the Hardware:

This section describes how to set up the various configurations of hardware to run this demo.

Configuration 1: PIC24FJ256GB110 PIM + Explorer 16

### Configuration 1: Explorer 16

1) Before attaching the PIC24FJ256GB110 PIM to the Explorer 16 board, insure that the processor selector switch (S2) is in the “PIM” position as seen in the image below.

2) Short the J7 jumper to the “PIC24” setting

3) Before connecting the PIC24FJ256GB110 PIM to the Explorer 16 board, remove all attached cables from both boards. Connect the PIC24FJ256GB110 PIM to the Explorer 16 board. Be careful when connecting the boards to insure that no pins are bent or damaged during the process. Also insure that the PIM is not shifted in any direction and that all of the headers are properly aligned.

4) On the USB PICTail Plus board, short jumper JP4. Remove all other shorts on the board.

5) Connect the USB PICTail Plus board to either of the female PICTail Plus connectors or on the card edge connector (J9) at the edge of the Explorer 16 board.

Note: When using the HID bootloader for PIC32, it is important to modify the procdefs.ld file to relocate the sections of code that will hold the bootloader and those sections that will hold the user application. Example modified procdefs.ld files have been provided with each project. This file is currently names “Procdefs.ld.boot”. When using the example project with the bootloader it is required to remove the “.boot” section of the file. This will allow MPLAB to use this file instead of the default linker file. Once the linker file is renamed, however, the project will no longer work without the bootloader. Please rename the file in order to get the project working again with PIC32.

Firmware:

To run this project, you will need to load the corresponding firmware into the devices. There are two methods available for loading the demos: Precompiled demos and source code projects.

Precompiled Demos are available in the “<Install Directory>\USB – Precompiled Demos” folders. Each demo should be prefaced with the hardware platform it is compiled for. Select the file that matches the hardware that you have and the demo that you want to run. For more information about how to load a precompiled project, please see the “Getting Started – Loading a precompiled demo” guide.

The source code for this demo is available in the “<Install Directory>\USB OTG – MCHPUSB – Generic Driver Demo” directory. In this directory you will find all of the user level source and header files as well as project and workspace files for each of the hardware platforms. Find the project (*.mcp) or workspace (*.mcw) file that corresponds to the hardware platform you wish to test. Compile and program the demo code into the hardware platform. For more help on how to compile and program projects, please refer to the MPLAB® help available through the help menu of MPLAB (Help->Topics…->MPLAB IDE).

Running the Demo:

This demo will require two Microchip devices to run. One will act as the USB host and the other will run the USB peripheral.

To demo the full OTG functionality, program 2 sets of boards with the code provided in the “USB OTG – MCHPUSB – Generic driver demo” folder.

Power both boards. For this demo you will need a micro-A to micro-B cable. At the time of this release these cables are rare and still hard to find. When purchasing a cable please insure that the ID pin on both connectors is correct. On the A side of the cable the ID pin should be less than 10 ohms to ground. On the B-side of the cable the ID pin should be more than 100k ohms to gnd. There are several manufactures that produce micro-A to micro-B cables that are not OTG compliant and these cables have the ID pin connected straight through the cable instead of grounded on one end and floating on the other as the OTG specification calls for.

When the A end of the cable is plugged into either of the boards, that board will become host. When the B end of the cable is connected to either of the boards, that board will become peripheral. On the host board, press the S3 button (seen below). This will cause the host to start supplying 5v to the peripheral. At this point the peripheral should start to operate.

Changing the POT on the peripheral board will cause the LCD on the host to reflect the new value. Similarly the temperature will be affected. Pressing S3 again will cause the host to power down the peripheral. With the power to the peripheral off, press the S3 button on the peripheral. This initiates a Session Request Protocol (SRP). This requests that the host power the bus again. At this point the device should run again without enabling the power from the device.

To switch roles, while both devices are power and the host is communicating to the peripheral, press the S6 button (seen below) on the host (the A device). This initiates a Host Negotiate Protocol (HNP). This causes the A device to become the peripheral and the B device to become the host. The demo is run the same as before except that the POT on the A device is now read on the LCD of the B device. To return to the original configuration, press the S6 button on the B device (now the host). This will suspend the bus and return host control to the A device.

Note: when bootloading this application using the HID bootloader, please make sure that the “Allow Configuration Word Programming” box is checked. This is required to be able to program the interrupt vectors on PIC24 products. As this demo requires interrupts it will not work without this feature enabled.

## Trademarks:

The Microchip name and logo, the Microchip logo, MPLAB, and PIC are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.

PICDEM is a trademark of Microchip Technology Incorporated in the U.S.A. and other countries.

Microsoft, Windows, and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.