Library 24- Virtual COM Port (VCP) for STM32F4

This library provides Virtual COM port on USB OTG. This means, that you don’t need external USB->UART converter (like FTDI) to communicate with computer. STM32F4xx will be seen to computer like COM port.

Library can be used on all STM32F4xx devices. It has also features to support STM32F4- and STM32F429 Discovery boards.

If you have USB->4 wires cable, you can connect both boards in both ways, but then you don’t have fancy connected.

Clock for STM32F429 was set down to 168MHz, because you can not get 48MHz for USB with 180MHz core clock

By default, library is set in FS mode, so pins PA11 and PA12 are in use. If you are working with STM32F429 Discovery board and you want to use microUSB connector instead of wires on pinheaders, then open your defines.h file and activate USB HS in FS mode:

Activate USB HS in FS mode

C

1

2

/* Activate USB HS in FS mode */

#define USE_USB_OTG_HS

You are now working in HS mode.

Default internal buffer size for received data is 128bytes. If you need more, you can set more in defines.h file using specific define:

Set custom buffer size

C

1

2

/* Custom buffer size */

#define USB_VCP_RECEIVE_BUFFER_LENGTH 128

When you connect board to USB to computer, there will be new COMx seen. For that, you also need USB VCP drivers provided by STMicroelectronics.

Note: In your terminal are options to set baudrate, stop bits, etc. Leave that at it is, these settings don’t care, because everything is configured by USB.

Precompiled versions

Some users has issues with setting project (example below) correctly (don’t know why) and I have precompile long time ago 2 versions of example for F4-Disco and F429-Discovery boards. This is now available here for download.