cancel
Showing results for 
Search instead for 
Did you mean: 

I want to send data from my Nucleo board to Matlab using the USB interface with the CDC protocol. But I am not able to open the port. What can I do to use the virtual COM port?

MScha.1
Associate II

Request for help with USB CDC interface

(STM32F401 Can not open Virtual Port)

I want to send data at about 5Mbit/s from my Nucleo board to Matlab using the USB interface with the CDC protocol. I have now managed to get the PC to recognize a "Serial USB device" on COM6. But I am not able to open the port, neither with Matlab nor with a terminal program (HTerm). What can I do to use the virtual COM port?

With the same setup I could already use the HID protocol. A mouse pointer example for deflecting the mouse pointer in X-direction ran successfully.

I would be very grateful if you could help me to use the virtual interface!

To the info:

I use the Nucleo F401RE board. The PC runs with Windows 10.

As tool chain I use:

  CubeMX 5.5.0 and

  SW4STM32 version Neon.3 release 4.6.3.

USB is connected as follows:

  D+ via a 1.5k pull up resistor to 3.3V of the Nucleo and connected to PA12

  D- connected with PA11

  The USB GND is connected to the Nucleo GND

  The USB VCC (+5V) is not connected

In CubeMX the following is set:

* Connectivity:

  USB_OTG_FS / Device_Only

  "Activate_SOF" and "Activate_VBUS" are inactive.

* Middleware: USB_Device / Communication Device Class (Virtual Port Com)

* In the Project I increased the minimum heap size from 0x100 to 0x800.

In the main.c program the following 3 additions are made:

1)

/* Private includes --------*/

/* USER CODE BEGIN Includes */

#include "usbd_cdc_if.h"

2)

/* USER CODE BEGIN 2 */

 HAL_Delay(1000);

 uint8_t buffer[] = "Hallo, Welt!\r\n";

3)

 /* USER CODE BEGIN WHILE */

 while (1)

 {

    CDC_Transmit_FS(buffer, sizeof(buffer));

    HAL_Delay(1000);

    HAL_GPIO_TogglePin(LD2_GPIO_Port,LD2_Pin);

0 REPLIES 0