Serial communication with custom STM32 board and windows device

Hi everyone, not sure if this is the right place to post this, but I am looking for a way to implement serial communication on a custom STM32 board via a USB port, solely with the bare STM32.

Ideally I would be able to plug in a USB cable into both my board and laptop and have windows recognize the device as some generic serial device, and allow me to use a serial monitor of some sort.

I’m fairly new to creating custom boards, and setting up serial devices in general so Im not sure if this is possible.

I’ve seen some examples creating a USBSerial device, and heard about talks of creating a virtual COM port, but im not sure how any of that works.

Any advice is appreciated,
thanks.

Hello,

section for custom targets - Custom and community boards - Arm Mbed OS support forum

You want to use on-chip USB controller and not an external one or UART to USB bridge, am I right?

You forgot to share:

  • with what MCU is your custom board equipped.
  • are you already able to run an debug your custom board?

BR, Jan

Posted this when I was tired and frustrated, ended up finding a solution.

To clarify,
I am using a custom board with an STM32F401CCUx MCU

This is correct, my board has pins PA12 and PA11 wired to the datalines on a usb connector, I was looking to have my windows pc recognize the board and be assinged a “COM” port

it ended up being as simple as

#include <USBSerial.h>
int main() {
    USBSerial pc(false);
    pc.printf("Hello World!");
}

This creates, from what I can tell, a virtual COM port, that does not require a separate interface

you can find references to USBSerial as well as other types of devices you can have in the docs and scrolling down to the USB drivers section