USB Component  Version 6.13.6
MDK Middleware for USB Device and Host Communication
 All Data Structures Functions Variables Enumerations Enumerator Groups Pages
USB Device Virtual COM Port

The Communication Device Class (CDC) is used for implementing virtual communication ports. This example demonstrates a bridge between a Virtual COM Port on the USB Host Computer and an UART port on the evaluation board.

The following picture shows an exemplary connection of the development board and the USB Host Computer.

cdc_dev_example_setup.png

The Abstract.txt file contained in the Documentation group of the Project window gives you more information on the general setup and the available I/O on the development board.

Build the "USB Device Virtual COM" Project

Open the example project in MDK. The ┬ÁVision Project window should display a similar project structure:

usb_cdc_example_proj_window.png
Typical Project Structure of an USB VCOM Example

Source Files

  • VirtualCOM.c contains the main C function that initializes the board hardware and the USB Device Component. Furthermore, it contains the code that exchanges the data internally between the USB and the UART port.
  • The USBD_User_CDC_0.c is an adapted code template that implements all necessary file access functions. Refer to CDC: Communication Device Class (ACM) for details about these template functions.

If you are using RTOS other than CMSIS-RTOS2 RTX5 for your project please make sure to satisfy USB Device Resource Requirements.

You may now build and download the example project to the evaluation board using the ┬ÁVision commands:

  • Project –> Build target (F7)
  • Flash   –> Download (F8)

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information.

Using the "USB Device Virtual COM" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Connect the UART on the development board to your PC (you might need an USB to serial RS232 adapter). Use an USB cable to connect your development board to the Host PC and power up your board.
  • The Welcome to the Found New Hardware Wizard appears. Installation of the driver is described in detail in the Abstract.txt file.

PC Software

The USB Device Virtual COM example can be tested on a Windows PC using a terminal emulation program. Since Hyperterminal in not part of Windows any more, please download an appropriate program for this purpose (such as PuTTY for example). Open the two COM ports "COMx" and "COMy". Any data from "COMx" will be echoed on "COMy" and visa versa:

vcom_terminals.png