STM32F103 Virtual COM
Example based on HAL libraries 

Home Page
STM32F4xx Page
STM32 Page

Date:       february 2016
Name:     USB Virtual COM (or USB CDC device)
Note:       This SW was tested on STM3210E-EVAL and compiled using the KEIL v.5.16a
STM3210E-EVAL page is here, on this board there is the: STM32F103ZE og ZG mcu (Cortex M3)
How to use:   
                Connect the 
STM3210E-EVAL USB to a PC.
                On the PC run TeraTerm and configure it with this parameters:
                                BaudRate:          115200
                                Data Bit:            8
                                Parity:                NONE
                                Stop Bit:            1
                                Flow Control:      NONE
                Any character typed on PC (using TeraTerm) is received from the
STM3210E-EVAL USB and it is sent back to the PC (again via USB Virtual COM).

Remember to instal on your PC the:
STM Virtual COM Port Driver that is here.

Below there are the TeraTerm SetUp

How to run this example

Download the example and unzip it.
Please ask me the password for unzip this example, see at the end of this page.
Go in the directory:
and run the:

SW explanations

Any character typed on PC (using TeraTerm) is received from the STM3210E-EVAL USB and it is sent back to the PC (again via USB Virual COM).

All is based on HAL Libraries.

The management of the USB Virtual COM is made in the file: usbd_cdc_interface.c
See the function: static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len)
from line n.332

This example is a modification of the original STM example, that use a USB Virtual COM for receives data and send it via USART (TX).
The data received from USART (RX) are sent via USB (Virtual COM) to PC.

The above function (USB - USART - USB) has been disabled.
To enable it remove the // from line n.334 and comment from the line n.338 to the line n.341.

As I already explained, this SW was tested on STM3210E-EVAL.
The STM3210E-EVAL use on pin USB_DP a couple of two BJT (T1 and T2) to connect the 1K5 resistor to 3V3.

If on your board, the USB_DP is connected directly to STM32F1xx (see below), substitute (in the project) the file: usbd_conf.c
with the file contained in the zip file:

Inside the there is the new usbd_conf.c that is compliant to the USB_DP connected directly to STM32F1xx.

The wiring from STM3210E-EVAL and PC

The jumpers on STM3210E-EVAL must be:

The SW is free and the Ref.Cod. is: STM3210E-EVAL-USBVirtualCOM
Please ask me the password for open the: STM3210E-EVAL-USBVirtualCOM
and specify also your City and Country.

Home Page
STM32 Page