Jump to main content

##

# 1.4 CDC MSD SD Card Example (cdc_msd_sdcard)

This application demonstrates the ability of the MPLAB Harmony USB Device Stack to support composite USB Device.

## Description

This application creates a USB CDC Device that enumerates as a COM port and Flash Drive simultaneously. The COM port can be opened using any of the terminal applications. To demonstrate two-way communication, a character typed on the terminal window is echoed back by the USB device. Flash drive acts similar to any Mass Storage Class device where the SD Card is used as storage media.

## Downloading and building the application

To clone or download this application from Github, go to the main page of this repository and then click Clone button to clone this repository or download as zip file. This content can also be downloaded using content manager by following these instructions.

Path of the application within the repository is usb_apps_device/apps/cdc_msd_sdcard.

Following table gives the details of project configurations, target device used, hardware and its IDE. Open the project using the respective IDE and build it.

Project Name | IDE | Target Device | Hardware / Configuration
--- | --- | --- | ---
pic32mx470_curiosity.X | MPLABX | PIC32MX470F512H | PIC32MX Curiosity Development Board
pic32mz_ef_curiosity_2_0.X | MPLABX | PIC32MZ2048EFM144 | Curiosity PIC32MZ EF 2.0 Development Board
sam_9x60_ek.X | MPLABX | SAM9X60 | SAM9X60-EK Evaluation Board
sam_9x60_curiosity.X | MPLABX | SAM9X60 | SAM9X60 Curiosity Development Board
sam_9x75_eb.X | MPLABX | SAM9X75 | SAM9X75-DDR3-EB Evaluation Board
sam_a5d2_xult.X | MPLABX | ATSAMA5D27C | SAMA5D2 Xplained Ultra Board
sam_a5d27_som1_ek.X | MPLABX | ATSAMA5D27C | SAMA5D27 SOM1 Kit1
sam_a5d27_wlsom1_ek1.X | MPLABX | ATSAMA5D27C | ATSAMA5D27 WLSOM1 EK1
sam_a7g5_ek.X | MPLABX | SAMA7G54 | SAMA7G5 EK Board
pic32cz_ca80_curiosity_ultra.X | MPLABX | PIC32CZ8110CA80208 | PIC32CZ CA80 Curiosity Ultra development board
pic32cx_sg41_curiosity_ultra.X | MPLABX | PIC32CX1025SG41128 | PIC32CX SG41 Curiosity Ultra Evaluation Board
sam_a5d29_curiosity.X | MPLABX | ATSAMA5D29 | SAMA5D29 Curiosity Development Board
sam_9x75_curiosity.X | MPLABX | SAM9X75D2G | SAM9X75-Curiosity Development Board
sam_a7d65_curiosity.X | MPLABX | SAMA7D65 | SAMA7D65 Curiosity Development Board
pic32ck_gc01_curiosity_ultra.X | MPLABX | PIC32CK2051GC01144 | PIC32CK GC Curiosity Ultra Development Board
pic32cm_gc_curiosity_pro.X | MPLABX | PIC32CM5112GC00100 | PIC32CM GC Curiosity Pro Board

## Configuring the Hardware

SAM9X60-EK Evaluation Board

- Setup the SD card (Note: exFAT formatted SD Cards are not supported)
  - Download harmony MPU bootstrap loader from this location.
  - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
  - Insert the SD card into the SDMMC connector J4 on the board.
  - Reset the board by pressing the Push Button SW3.
- Jumpers J20, J21, and J13 must be open.
- Jumper J2 and J3 must be shorted.
- Connect the USB Micro-B port J22 on board to the computer using a micro USB cable (to enable the debug com port).
- Connect the USB Micro-B Connector (J7) on the board to the computer using a micro USB cable.
- LED D1 indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
- Press the switch SW1 to trigger communication from the USB Device to the USB Host.
  Note: Reset push button on SAM9X60 EK is labeled as SW3
  SAM9X60-Curiosity Board
  - Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    - Download harmony MPU bootstrap loader from this location.
    - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    - Insert the SD card into the SDMMC0 connector J3 on the board.
    - Reset the board by pressing the Push Button "RESET".
  - Jumper J4 must be shorted.
  - Connect the USB Micro-B Connector (J1) on the board to the computer using a micro USB cable.
  - LED D1 indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
  - Press the switch "USER" to trigger communication from the USB Device to the USB Host.
  SAMA5D2 Xplained Ultra Board
  - Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    - Download harmony MPU bootstrap loader from this location.
    - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    - Insert the SD card into the SDMMC1 slot on the board.
    - Reset the board by pressing the Push Button BP3.
  - Short jumper JP2(DEBUG_DIS).
  - Connect the EDBG USB Micro-B port J14 on the board to the computer using a micro USB cable.
  - Use the "A5-USB-A" connector (J23 - Micro A/B connector) on the board to connect the USB device to the USB Host.
  - RGB LED turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
  - Press PB_USER Switch to trigger communication from the USB Device to the USB Host.
  Curiosity PIC32MX470 Development Board
  - To run the demo, the following additional hardware is required:
    - micro-sd Click board
    - micro-sd card
  - Insert the micro-sd click board into the Mikro BUS 1 connector on the Curiosity PIC32MX470 Development Board.
  - Insert the micro-SD card into the micro-SD Card slot of the micro-sd click board.
  - USB micro-B port J12 to connect the USB device to the USB Host PC.
  - LED1 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
  - Press the switch S1 to trigger communication from the USB Device to the USB Host.
  Curiosity PIC32MZ EF 2.0 Development Board
  - To run the demo, the following additional hardware is required:
    - micro-sd Click board
    - micro-sd card
  - Insert the micro-sd click board into the Mikro BUS 1 connector on the Curiosity PIC32MZ EF 2.0 Development Board.
  - Insert the micro-SD card into the micro-SD Card slot of the micro-sd click board.
  - Use the USB micro-B port J201 to connect the USB Device to the USB Host PC.
  - LED1 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
  - Press the switch SW1 to trigger communication from the USB Device to the USB Host.
  PIC32CM GC Curiosity Pro Board
  - To run the demo, the following additional hardware is required:
    - micro-sd Click board
    - micro-sd card
  - Insert the micro-sd click board into the Mikro BUS connector on thePIC32CM GC Curiosity Pro Board.
  - Insert the micro-SD card into the micro-SD Card slot of the micro-sd click board.
  - Use TARGET USB connector (J200 ) on the board to connect the USB Device to the USB Host PC.
  - LED1 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
  - Press the switch SW0 to trigger communication from the USB Device to the USB Host.
  SAMA5D27 SOM1 Kit1
  - Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    - Download harmony MPU bootstrap loader from this location.
    - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    - Insert the SD card into the SDMMC0 slot (J12) on the board.
    - Reset the board by pressing the Push Button PB1.
  - Connect the Debug USB port (J10) on the board to the computer using a micro USB cable.
  - Connect the USB Micro-B Connector (J17) on the board to the computer using a micro USB cable.
  - RGB LED turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
  - Press the Push button PB4 to trigger communication from the USB Device to the USB Host.
  ATSAMA5D27-WLSOM1 Evaluation Kit
  - Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    - Download harmony MPU bootstrap loader from this location.
    - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    - Insert the SD card into the SDMMC0 Card Connector (J9) on the board.
    - Reset the board by pressing the Reset Button (SW2)
  - Connect the USB-A Micro AB connector (J10) on the board to the computer using a micro USB cable.
  - Press the "START_SOM" button to activate board start-up.
  - RGB LED turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
  - Press the Push button SW4 to trigger communication from the USB Device to the USB Host.
  SAMA7G5-EK Evaluation Kit
  - Powered the board with an external power supply (J1) or power supply the board by connecting J7 to the computer using a micro USB cable.
  - Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    - Download harmony MPU bootstrap loader from this location.
    - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    - Insert the SD card into the SD Card Connector (J4) on the board.
    - Reset the board by pressing the Reset Button (nRST)
  - Press the "nSTART" button to activate board start-up.
  - Connect the USB Micro AB connector (J7) to the computer using an USB cable.
  - RGB LED turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
  - Press the USER BUTTON SW1 to trigger communication from the USB Device to the USB Host.
  PIC32CZ CA80 Curiosity Ultra development board
  - To run the demo, the following additional hardware is required:
    - micro-sd card
  - Insert the SD card into the SD Card Connector (J600) on the board.
  - Use the USB micro-B port J102 to connect the USB Device to the USB Host PC.
  - LED0 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
  - Press the switch SW0 to trigger communication from the USB Device to the USB Host.
  PIC32CX SG41 Curiosity Ultra Evaluation Board
  - To run the demo, the following additional hardware is required:
    - micro-sd card
  - Insert the SD card into the SD Card Connector (J704) on the board.
  - Use the USB micro-B port J200 TARGET USB to connect the USB Device to the USB Host PC.
  - LED1 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
  - Press the switch SW1 to trigger communication from the USB Device to the USB Host.
- PIC32CK GC Curiosity Ultra Development Board
  - To run the demo, the following additional hardware is required:
    - micro-sd card
  - Insert the SD card into the SD Card Connector (J600) on the board.
  - Use the Barrel jack connector(J200) to connect an external power supply to the board.
  - Use the USB Type-C connector (J202) to connect the USB Device to the USB Host PC.
  - LED0 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
  - Press the switch SW0 to trigger communication from the USB Device to the USB Host.
- SAM9X75-DDR3-EB Evaluation Board
  - Powered the board with an external power supply (or use the micro AB connector).
  - Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    - Download harmony MPU bootstrap loader from this location.
    - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    - Insert the SD card into the SDMMC connector (SDMMC0) on the board.
    - Reset the board by pressing the Push Button RESET, then START.
  - Connect USB to serial cable to DBGU0 (to enable debug com port).
  - Connect the USB Micro-AB Connector on the board to the computer using a micro USB cable.
  - LED near VDDCORE inscription on the board indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
  - Press the switch USER to trigger communication from the USB Device to the USB Host.

SAMA5D29 Curiosity Development Board

- Setup the SD card (Note: exFAT formatted SD Cards are not supported)
  - Download harmony MPU bootstrap loader from this location.
  - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
  - Insert the SD card into the μSD-CARD connector (J6) on the board.(This connector is present on the bottom face of the board)
  - Reset the board by pressing the Push Button RESET.
- Press the "START" button to activate board start-up.
- Insert an SD Card to the SDMMC1 connector(J7).
- Connect the USB Type-C (USB-A) Connector (J1) on the board to the computer using a USB Type-C cable.
- RGB LED (D5) turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
- Press the "USER" Push Button (SW1) to trigger communication from the USB Device to the USB Host.

SAM9X75-Curiosity Development Board

- Setup the SD card (Note: exFAT formatted SD Cards are not supported)
  - Download harmony MPU bootstrap loader from this location.
  - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
  - Insert the SD card into the μSD-CARD connector (J14) on the board.
  - Reset the board by pressing the Push Button RESET.
- Press the "START" button to activate board start-up.
- Connect the USB Micro-B (USB_A) Connector (J2) on the board to the computer using a USB cable.
- RGB LED (LD1) turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
- Press the "USER" Push Button (SW2) to trigger communication from the USB Device to the USB Host.

SAMA7D65 Curiosity Development Board

- Setup the SD card (Note: exFAT formatted SD Cards are not supported)
  - Download harmony MPU bootstrap loader from this location.
  - Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
  - Insert the SD card into the SD-CARD connector (J10) on the board.
  - Reset the board by pressing the Push Button RESET.

- Press the "START" button to activate board start-up.
- Connect the USB Type-C Connector (J3) on the board to the computer using a USB cable.
- RGB LED turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
- Press the "USER" Push Button (SW3) to trigger communication from the USB Device to the USB Host.

## Running the Application

This demonstration application creates a composite USB Device that works simultaneously as a CDC and as a MSD device. This application combines the functionality of the cdc_com_port_single and msd_sdcard demonstration applications into one device.

Open the project with appropriate IDE. Compile the project and program the target device.

Running the CDC Device

The CDC Device application is same as cdc_com_port_single demo. Refer to local documentation from usb_apps_device/apps/cdc_com_port_single. The documentation is also available in the github path usb_apps_device/apps/cdc_com_port_single.

Running the MSD SD Card Device

The MSD Basic Device application is same as msd_sdcard demo. Refer to local documentation from usb_apps_device/apps/msd_sdcard. The documentation is also available in the github path usb_apps_device/apps/msd_sdcard.