1.5 HUB CDC HID Example (hub_cdc_hid)

This application demonstrates the ability of the MPLAB Harmony USB Host Stack to access and manage multiple USB Devices through a Hub.

Description

This application creates a USB Host that can recognize and enumerate a CDC Emulator USB Device and a HID USB Mouse connected via an external Hub. The host will demonstrate the communication from the CDC emulator device and the HID mouse.

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_host/apps/hub_cdc_hid.

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 NameIDETarget DeviceHardware / Configuration
pic32mz_ef_curiosity_2_0.XMPLABXPIC32MZ2048EFM144Curiosity PIC32MZ EF 2.0 Development Board
pic32mz_ef_sk.XMPLABXPIC32MZ2048EFH144PIC32MZ Embedded Connectivity with FPU (EF) Starter Kit
sam_9x75_eb.XMPLABXSAM9X75SAM9X75-DDR3-EB Evaluation Board
sam_g55_xpro.XMPLABXATSAMG55J19SAMG55 Xplained Pro Board
pic32cz_ca80_curiosity_ultra.XMPLABXPIC32CZ8110CA80208PIC32CZ Curiosity Development Board
pic32ck_gc01_curiosity_ultra.XMPLABXPIC32CK2051GC01144PIC32CK GC Curiosity Ultra Development Board
wbz653_curiosity.XMPLABXWBZ653WBZ653 Curiosity Board

Configuring the Hardware

PIC32CZ CA80 Curiosity Development Board
  • A commercially available USB Mouse is required to run this demonstration application.
  • Connect the USB Hub to the connector (J102) using a USB Type-A Female to micro-B male cable (This cable is not included in the kit).
  • LED0 is controlled by the attached USB Mouse.
  • LED0 is also controlled by the attached USB CDC Device.
PIC32CK GC Curiosity Ultra Development Board
  • An external power supply (6.5V to 14V) must be connected through the J200 connector.
  • A commercially available USB Mouse is required to run this demonstration application.
  • Connect the USB Hub to the USB Type-C connector (J202). A USB Type-C to Type-A Female adapter is required to connect the USB device to the board. (This adapter is not included in the kit)
  • LED1 is controlled by the attached USB Mouse.
  • LED1 is also controlled by the attached USB CDC Device.
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 an USB to serial cable to DBGU0 (to enable debug com port).

  • Connect the USB Hub to the Type-A connector or to the micro AB with a specific dongle (in these case the need to be powered by the external power supply).

  • LED near VDDCORE inscription on the board is controlled by the attached USB Mouse.

  • LED near VDDCORE inscription on the board is also controlled by the attached USB CDC device.
    SAMG55 Xplained Pro Board
    • Chip Erase Jumper must be open.
    • Connect the USB device to the "TARGET USB" connector using a USB Type-A Female to micro-B male cable (This cable is not included in the kit).
    • LED0 on the board is controlled by the attached USB CDC device.
    Curiosity PIC32MZ EF 2.0 Development Board
    • Connect the USB device to the "TARGET USB" connector (J201) using a USB Type-A Female to micro-B male cable (This cable is not included in the kit).
    • LED1 is controlled by the attached USB Mouse.
    • LED1, LED2, and LED3 are controlled by the attached USB CDC Device.
    PIC32MZ Embedded Connectivity with FPU (EF) Starter Kit
    • Connect the USB Hub to the Type A connector J5, which is located on the top side of the starter kit.
    • LED1 is controlled by the attached USB Mouse.
    • LED1, LED2, and LED3 are controlled by the attached USB CDC Device.
WBZ653 Curiosity Board
  • Connect a Type-C cable between the DBG USB (J100) port on the board and the PC to power up the board.
  • The Jumper J102 must be shorted between 5V and VBUS.
  • The Jumper J104 must be connected between VBUSON and EN (Positions 2 and 3).
  • A commercially available USB Mouse is required to run this demonstration application.
  • Connect the USB Hub to the USB Type-C connector TARGET USB (J103). A USB Type-C to Type-A Female adapter is required to connect the USB device to the board (This adapter is not included in the kit).
  • The RGB_LED (D800) turning Green is controlled by the attached USB Mouse.
  • The RGB_LED (D800) turning Green is also controlled by the attached USB CDC Device.

Running the Application

This application demonstrates the capability of the USB Host Stack to access and manage multiple USB Devices through a Hub. The demonstration application enumerates a HID mouse and CDC emulator device via an external hub. The host will demonstrate the communication from the CDC emulator device and the HID mouse.

  1. Open MPLAB X IDE the project corresponding to the selected board. Refer to the Building the Application section for details.
  2. Build the code and program the device.
  3. Connect a USB hub to the Host connector on the desired board.
  4. Connect a USB mouse to a spare port on the hub.
  5. Click the mouse Left and Right buttons. This will toggle LED on the demo board.
  6. Follow the directions for setting up and running the cdc_serial_emulator USB device demonstration. Start a terminal program on the USB Host personal computer and select the Serial-to-USB Dongle as the communication port. Select the baud rate as 9600, no parity, One Stop bit, and no flow control.
  7. Connect the CDC emulator device to another spare port on the hub.
  8. The LED on the USB host board will turn on as soon as the CDC device is connected. Refer to the Configuring the Hardware section for details on the relevant LED.
  9. The terminal emulator program will immediately display the text "LED ON."
  10. Pressing the key "1" on the terminal will cause the LED on the Host USB board to switch on. Pressing any other key on the terminal message will cause the LED to switch off.
  11. The above step can be repeated.
  12. Ensure that the CDC serial emulator device is completely powered off before detaching and reattaching to the embedded CDC host.