Getting Started: Running the “Device – Mass Storage – Internal Flash” demo

Required Hardware: 1

Configuration 1: PIC18F87J50 PIM... 1

Configuration 2: Explorer 16. 1

Configuration 3: PIC24F Starter Kit 1. 1

Configuration 4: PIC18F46J50 Full Speed USB Demo Board. 2

Configuration 5: PICDEM FS USB.. 2

Configuration 6: PIC18F Starter Kit 2

Configuration 7: PIC32 USB Starter Board. 2

Configuring the Hardware: 2

Configuration 1: PIC18F87J50 PIM... 2

Configuration 2: Explorer 16. 3

Configuration 3: PIC24F Starter Kit 1. 5

Configuration 4: PIC18F46J50 Full Speed USB Demo Board. 6

Configuration 5: PICDEM FS USB.. 6

Configuration 6: PIC18F Starter Kit 6

Configuration 7: PIC32 USB Starter Board. 7

Firmware. 7

Running the Demo. 8

Toubleshooting Tips. 8

Trademarks: 9

## Required Hardware:

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

### Configuration 1: PIC18F87J50 PIM

PIC18F87J50 Plug-In-Module (PIM) (MA180021)

High pin count (HPC) Explorer (DM183022)

SD Card PICTail™ Plus Daughter Card (AC164122)

### Configuration 2: Explorer 16

Explorer 16 (DM240001)

USB PICtail™ Plus Daughter Card (AC164131)

And one of the following PIMs

PIC24FJ64GB004 Plug-In-Module (PIM) (MA240019)

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

PIC32MX460F512L Plug-In-Module (PIM) (MA320002)

PIC32MX795F512L Plug-In-Module (PIM) (MA320003)

dsPIC33EP512MU810 USB Plug-In-Module (PIM)

PIC24EP512GU810 USB Plug-In-Module (PIM)

### Configuration 3: PIC24F Starter Kit 1

PIC24F Starter Kit 1 (DM240011)

### Configuration 4: PIC18F46J50 Full Speed USB Demo Board

PIC18F46J50 Full Speed USB Demo Board (MA180024)

### Configuration 5: PICDEM FS USB

PICDEM FS USB (DM163025)

### Configuration 6: PIC18F Starter Kit

PIC18F Starter Kit (DM180021)

### Configuration 7: PIC32 USB Starter Board

PIC32 USB Starter Board (DM320003)

##

## Configuring the Hardware:

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

Configuration 1: PIC18F87J50 PIM

Configuration 2: Explorer 16

Configuration 3: PIC24F Starter Kit 1

Configuration 4: PIC18F46J50 Full Speed USB Demo Board

Configuration 5: PICDEM FS USB Board

Configuration 6: PIC18F Starter Kit

Configuration 7: PIC32MX USB Starter Board

### Configuration 1: PIC18F87J50 PIM

1) Short JP4 on the PIC18F87J50 PIM. This allows the demo board to be powered through bus power.

2) Short JP1 such that the “R” and “U” options are shorted.

### Configuration 2: Explorer 16

1) Before attaching the 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 PIM to the Explorer 16 board, remove all attached cables from both boards. Connect the 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.

3a) If using the PIC24FJ64GB004 PIM, please insure that the programming port switch is switched in the PGX1 direction.

4) On the USB PICTail Plus board, short jumper JP1. 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 named “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.

### Configuration 3: PIC24F Starter Kit 1

The PIC24F Starter Kit does not require any hardware setup to run this demo. This demo does, however, require the user to change the default selected device in the project before compiling the demo.

1) Open the associated project file for C30

2) In MPLAB Select “Configure->Select Device”

3) In the device list box in the top left corner of that window, select “PIC24FJ256GB106”

### Configuration 4: PIC18F46J50 Full Speed USB Demo Board

1) Short JP3 to allow the board to be powered from the USB.

### Configuration 5: PICDEM FS USB

1) If using the PICDEM FS USB Demo Board, no hardware related configuration or jumper setting changes should be necessary. The demo board need only be programmed with appropriate firmware.

### Configuration 6: PIC18F Starter Kit

No specific hardware configuration is required for this demo.

### Configuration 7: PIC32 USB Starter Board

No specific hardware configuration is required for this demo.

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 Device – Mass Storage – Internal Flash” 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® IDE help available through the help menu of MPLAB (Help->Topics…->MPLAB IDE).

Please note that when using either the C30 or C32 demo projects you will be required to select the correct processor for the demo board.

1) Open the associated project file

2) In MPLAB Select “Configure->Select Device”

3) In the device list box in the top left corner of that window, select the desired device.

Running the Demo:

This demo uses the selected hardware platform as an drive on the computer using the internal flash of the device as the drive storage media. Connect the hardware platform to a computer through a USB cable.

The device should appear as a new drive on the computer named “Drive Name”. The volume label or file information can be changed in the Files.c file located in the project directory.

Toubleshooting Tips:

Issue 1: The device appears correctly in the device manager, but no new drive letters appear on a Windows® operating system based machine.

Solution: See Microsoft knowledge base article 297694:

http://support.microsoft.com/kb/297694

If there is a drive letter conflict (ex: because a network drive has been mapped to a letter low in the alphabet), on some operating systems the newly attached USB drive may not appear. If this occurs, either obtain the hotfix from Microsoft, or remap the conflicting mapped network drive to a letter at the end of the alphabet (ex: Z:).

Issue 2: The device enumerates correctly and I can access the new drive. Even though the drive is not full yet, when I try to write to the drive, I get an error message something like, “Cannot copy (some name): The directory or file cannot be created.”

Solution: In order to copy new files onto the drive volume, both the file contents themselves must be copied to the drive, and the FAT table must also be updated in order to accommodate the new file name and path. Even if the drive has plenty of free space available, the FAT table may have reached its limit. In order to keep the default demos small, the FAT table is configured to be only 512 bytes long. This is not very large, and can easily be exceeded, especially if the files on the drive have long file names. In order to use the remaining space available on the drive, it is recommended to keep the individual file names as short as possible to minimize their size in the FAT table. Alternatively, the firmware can be modified so that the FAT table is larger, and therefore able to accommodate more file name and path characters.

Issue 3: When I try to format the drive, I get an error message and the drive does not get formatted properly.

Solution: By default, common Windows based operating systems will try to place a large FAT table on the newly formatted disk (larger than the default 512 bytes of the demo firmware). If the FAT table is larger than the total drive space, the drive cannot be formatted. In order to successfully format the drive, an alternative method of formatting will be needed that places a smaller FAT table on the drive. For example, the drive can be effectively reformatted by reprogramming the microcontroller with the original HEX file. Alternatively, if the firmware is modified to increase the total drive space, the Windows operating system managed FAT table may be able to fit. Unfortunately, this will shrink the effective drive size, making less of it available for actual file data.

Issue 4: When I format the drive, the drive size shrinks.

Solution: See the solution to issue #3 above.

## 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 and PICTail are trademarks 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.

SD is a trademark of the SD Association in the U.S.A and other countries