STM32 USB_CDC Configuration

STM32 USB_CDC Configuration

Preface:

We have to have some preparation to do before:
1, PC upload virtual serial port driver more than a good VCP1.31
2, prepare a USB-STM32 (connected to the USB interface, not serial USB)
3, installed STM32CUBEMX, and Download the latest package of good STM32F1
4, installed keil / iar compiler, etc.

Configuration Roadmap

1, first configure the STM32 clock
Here Insert Picture Description2, Enabling USB devices
Here Insert Picture DescriptionNote: If F4 and the like, not only has this option, but the name has not changed.

3, USB device is configured as a virtual port mode
Here Insert Picture Description4, to generate engineering and open, I use a 5.25 Keil
Here Insert Picture Description5, compile it lacks the problem, call the send function
Here Insert Picture DescriptionHere Insert Picture DescriptionNote: Do not forget to add in the main function in the header file

#include "usbd_cdc_if.h"

The final result:
Here Insert Picture Description

Published 45 original articles · won praise 52 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_42312125/article/details/104943858