© 2005 Microchip Technology Inc. DS01003A-page 9
AN1003
• START/STOP (Opcode 1Bh)
The START/STOP command requests that the
device server change the power condition of the logical unit, or load, or eject the medium. This includes
specifying that the device server enable or disable
the direct access block device for medium access
operations by controlling power conditions and timers. The POWER CONDITION field (fifth byte, bit 7-4)
is used to specify that the logical unit be placed into
a power condition or to adjust a timer. If the value of
this field is not equal to 0h, the START (fifth byte,
bit 0) and LOEJ (Load Eject, fifth byte, bit 1) bits are
ignored. If the POWER CONDITION field is Active
(1h), Idle (2h) or Standby (3h), then the logical unit
shall transition to the specified power. If POWER
CONDITION = 0h (START_VALID), then the START,
LOEJ = (0,0) signifies that the logical unit shall
transition to the stopped power condition; START,
LOEJ = (0,1) signifies the logical unit shall unload
the medium; START, LOEJ = (1,0) signifies that
the logical unit shall transition to the active power
condition. If START, LOEJ = (1,1), then the
logical unit shall load the medium.
UNSUPPORTED COMMANDS
If the command opcode field in the CBWCB is not
supported, the SENSE KEY is set to Illegal Request,
indicating that there was an illegal parameter in the
CDB with ASC and ACSQ codes set corresponding to an
invalid command opcode.
MASS STORAGE DEVICE (MSD)
FIRMWARE
This firmware implements a USB-based Mass Storage
Device using an SD card. When plugged into the USB
port, the firmware enumerates the SD card as a removable disk drive and allows the user to exercise all
standard features of a disk drive. The user can write,
read, edit and delete files on the MSD just like any other
removable disk media. This application also allows the
user to format the SD card in any of the following FAT file
formats: FAT16, FAT32 or NTFS (Windows drivers handle the format, firmware is only required to implement
the SCSI commands). The firmware calculates the
capacity of the SD card based on the Card Specific Data
(CSD) register read from the SD card. This information
is conveyed to the PC host in response to the READ
CAPACITY command. The exact size of the disk can be
seen in the disk properties on the PC. Further details on
firmware and SCSI command implementation can be
found in “SCSI Commands”.
The project framework is organized under a single root
directory with each subdirectory containing files for
each category or class of source code. If the SD card is
not found, or not initialized, the 4 LEDs (D1, D2, D3 and
D4) on the demonstration board are turned on
permanently.
Using the PICtail™ Board for SD™ and
MMC Cards
First, connect the demonstration board to the MPLAB
®
ICD 2 and program the device. The following steps are
required to run the MSD application:
1. Connect the PICtail™ Board for SD™ and MMC
Cards to the PICDEM FS USB Demonstration
Board as shown in Figure 1.
2. Insert the SD card in the reader slot, making
sure that write-protect is disabled on the SD
card.
3. Apply power to the demonstration board.
4. Observe the LEDs (D1, D2, D3 and D4) on the
demonstration board. If all of the LEDs are ON,
this indicates an SD card initialization failure.
5. If no errors have occurred, connect a USB cable
from the PC to the USB connector on the
demonstration board.
6. Observe under Control Panel > System >
Hardware > Device Manager (for Windows XP
system) that USB Mass Storage Device gets
enumerated under Universal Serial Bus
controllers. Verify that the Microchp Mass
Storage USB Device is enumerated under Disk
drive and Generic volume is enumerated
under Storage volumes, as shown in Figure 5.
7. Look for a removable drive under My
Computer.
8. Use the removable drive icon to access the SD
card as a MSD.
9. Before removing the USB cable from the demo
board, click the “Safely Remove Hardware”
icon in the Windows task bar.
The four LEDs on the PICDEM FS USB Demonstration
Board have been implemented as follows:
1. LED D1 turns ON after successfully responding
to the INQUIRY command.
2. LED D2 toggles ON after each successful TEST
UNIT READY command execution.
3. LED D3 blinks during read operation (turns ON
while a read from the SD card is taking place).
4. LED D4 blinks during write operation (turns ON
while a write to the SD card is taking place).