5.3.6 USB CDC Peripheral Transparent UART
BLE and this application demonstrates a combined USB and Bluetooth Low Energy (BLE) peripheral solution implemented using the PIC32-BZ6 Curiosity Board. It integrates a USB Communication Device Class (CDC) virtual COM port interface and BLE connectivity, providing seamless bidirectional data exchange between a USB host (such as a PC terminal application) and a remote BLE central device (mobile phone).
The application works in two primary data-flow modes:
- USB-to-BLE: Data entered from a USB host via the CDC COM port is received by the PIC32-BZ6 device and then transmitted wirelessly using BLE to a connected central device.
- BLE-to-USB: Data received wirelessly via BLE from the connected central device is relayed by the PIC32-BZ6 device over the USB CDC interface to the USB host.
This solution was implemented using Microchip’s MPLAB X Integrated Development Environment (IDE) and Harmony software framework enabling handling of simultaneous USB and BLE communications
Users can choose to either run the precompiled Application Example hex file provided on the PIC32-BZ6 Curiosity board and experience the demo.
Recommended Readings
-
Getting Started with Application Building Blocks – See Building Block Examples from Related Links.
- Getting Started with Peripheral Building Blocks – See Peripheral Devices from Related Links.
-
BLE Software Specification – See MPLAB® Harmony Wireless BLE in Reference Documentation from Related Links.
- FreeRTOS and BLE Stack Setup – See Peripheral - FreeRTOS BLE Stack and App Initialize from Related Links.
Hardware Required
S. No. | Tool | Quantity |
---|---|---|
1 | PIC32-BZ6 Curiosity Board | 1 |
2 | USB cable | 1 |
3 | Android/iOS Smartphone | 1 |
SDK Setup
Refer to Getting Started with Software Development from Related Links.
Software
To install Tera Term tool, refer to the Tera Term web page in the Reference Documentation from Related Links.
Smartphone App
Microchip Bluetooth Data iOS/Android app available in stores
Programming the Precompiled Hex File or Application Example
Using MPLAB® X IPE:
- Import and program the
precompiled hex file:
<Harmony Content Path>\wireless_apps_pic32_bz6
.\apps\ble\peripheral_applications \ usb_cdc_peripheral_trp_uart \precompiled_hex\ usb_cdc_peripheral_trp_uart.X.production.signed.hex
- For detailed steps, refer to
Programming a Device in MPLAB® IPE in
Reference Documentation from Related Links.Note: Ensure to choose the correct Device and Tool information.
Using MPLAB® X IDE:
- Perform the following the steps mentioned in Running a Precompiled Example. For more information, refer to Running a Precompiled Application Example from Related Links.
- Open and program the application:
<Harmony Content Path>\wireless_apps_pic32_bz6\apps\peripheral_applications\usb_cdc_peripheral_trp_uart\firmware\usb_cdc_peripheral_trp_uart.X
-
For more details on how to find the Harmony Content Path, refer to Installing the MCC Plugin from Related Links.
Demo Description
This demonstration illustrates a dual-interface USB and BLE peripheral solution implemented on the PIC32-BZ6 Curiosity Board. It highlights the integration of Bluetooth® Low Energy (BLE) peripheral functionality built on top of a USB CDC peripheral, facilitating seamless two-way communication between a USB host and a BLE central device.
The application uses Microchip’s BLE Transparent UART Profile and Service, allowing data to be transparently exchanged over the BLE connection without additional formatting or parsing. USB data received via the CDC virtual COM port is immediately relayed over BLE using notifications, while incoming data from the BLE central device is directly forwarded to the USB host, showcasing efficient bidirectional communication.
Testing
- Connect a Type-C cable between the DBG USB (J100) port on the Curiosity board and the PC to power up the board.
- The jumper (J102) must be open for USB device applications.
- Use the Target USB (J103) connector on the board to connect the USB Device to the USB Host PC.
- RGB_LED (D800) turning Green indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Program the precompiled hex file or application example as mentioned.
- Open Tera Term:
- Set the “Serial Port” to USB Serial Device.
- Speed to 115200.
- Press the NMCLR Button on the Curiosity board.
- Open the Microchip Bluetooth
Data (MBD) app on your smartphone and select “BLE UART” sub app.
- Select “PIC32CXBZ”.
- Press Scan for
advertisements. A device with the name “pic32cx-bz6” will appear. Select the
device and establish connection.
- Upon connection the serial terminal will display the “Connected” log.
- Select the “Text Mode” from
the bottom tab and start exchanging data bidirectionally between the serial
terminal and mobile application.
- Console log.