Jump to main content

##

# 1.10 HID Keyboard Example (hid_keyboard)

This application demonstrates the ability of the MPLAB Harmony USB Device Stack to support Generic HID keyboard.

## Description

This demonstration application creates a Generic HID keyboard. Pressing a switch on the target board emulates a keyboard key press.

## 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/hid_keyboard.

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
--- | --- | --- | ---
pic32mz_ef_curiosity_2_0.X | MPLABX | PIC32MZ2048EFM144 | Curiosity PIC32MZ EF 2.0 Development Board
pic32mx470_curiosity.X | MPLABX | PIC32MX470F512H | PIC32MX Curiosity Development Board
sam_9x75_eb.X | MPLABX | SAM9X75 | SAM9X75-DDR3-EB Evaluation Board
sam_9x75_curiosity.X | MPLABX | SAM9X75D2G | SAM9X75-Curiosity Development Board
sam_e70_xult.X | MPLABX | ATSAME70Q21B | SAM E70 Xplained Ultra Board
sam_e70_xult_freertos.X | MPLABX | ATSAME70Q21B | SAM E70 Xplained Ultra Board
pic32cz_ca70_curiosity_ultra.X | MPLABX | PIC32CZ2051CA70144 | PIC32CZ CA70 Curiosity Ultra Development Board
pic32cz_ca70_curiosity_ultra_freertos.X | MPLABX | PIC32CZ2051CA70144 | PIC32CZ CA70 Curiosity Ultra Development 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
pic32ck_gc01_curiosity_ultra.X | MPLABX | PIC32CK2051GC01144 | PIC32CK GC Curiosity Ultra Development Board
pic32cm_gc_curiosity_pro.X | MPLABX | PIC32CM5112GC00100 | PIC32CM GC Curiosity Pro Development Board

## Configuring the Hardware

Curiosity PIC32MZ EF 2.0 Development 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 Switch SW1 to exercise the keyboard key press function.

Curiosity PIC32MX470 Development Board

- Use the 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.

PIC32CZ CA80 Curiosity Ultra development board

- Use the USB micro-B "USB DEVICE" connector (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 S1 to trigger communication from the USB Device to the USB Host.

PIC32CX SG41 Curiosity Ultra Evaluation Board

- Use the USB micro-B "TARGET USB" connector (J200) 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.

SAM E70 Xplained Ultra Board

- Jumper J203 must be shorted between PB08 and VBUS (positions 2 and 3).
- Use TARGET USB J200 connector on the board to connect the USB Device to the USB Host PC.
- LED3 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host). LED3 also indicates status of Caps Lock on the PC.
- Press Switch SW400 to exercise the keyboard key press function.

PIC32CZ CA70 Curiosity Ultra board

- Use TARGET USB J203 connector on the board 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). LED0 also indicates status of Caps Lock on the PC.
- Press Switch SW0 to exercise the keyboard key press function.

PIC32CM GC Curiosity Pro board

- Use TARGET USB connector (J200 ) on the board 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). LED0 also indicates status of Caps Lock on the PC.
- Press Switch SW0 to exercise the keyboard key press function.

PIC32CK GC Curiosity Ultra Development 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). LED0 also indicates status of Caps Lock on the PC.
- Press Switch SW0 to exercise the keyboard key press function.

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).
- The demonstration uses an USB to serial cable to transfer demonstration application messages on a PC.
- Press switch USER to exercise the keyboard key press function.

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).
- The demonstration uses an USB to serial cable to transfer demonstration application messages on a PC.
- Press switch USER to exercise the keyboard key press.

## Running the Application

This demonstration uses the selected hardware platform as a USB keyboard. Open the project with appropriate IDE. Compile the project and program the target device.

The LEDs on the demonstration board will indicate the USB state of the device, as described in the Configuring the Hardware section.

Before pressing the button, select a window in which it is safe to type text freely. Pressing the button on the demonstration board will cause the device to print a character on the screen. LED on the board will also indicate the current CapsLock key status.

Note: If the Caps lock status on the PC is OFF when the device was attached the LED will turn ON and immediately turn off.