STM32CubeMX USB CDC VCP?

后端 未结 3 1279
一向
一向 2020-12-14 12:18

I\'ve found large number of examples, but nothing on how to do it \"properly\" from STM32MXCube.

How do I create skeleton code from STM32CubeMX for USB CDC virtual C

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 13:06

    There are a number of STM32F4 Discovery boards supported by the STM32Cube software, and you haven’t said which you’re using, but I’ve had exactly the same issue with the Discovery board with the F401VCT MCU.

    After installing the STM virtual COM port driver, Windows Device Manager showed a STMicroelectronics virtual COM port, but with a yellow warning mark. The COM port was not accessible with a terminal application (PuTTY).

    I eventually found that there is a problem with source code output from the STMCube program. But there is a simple fix:

    1. Open a new STM32Cube project and enable the USB_OTG_FS as Device Only and select CDC Virtual Port COM from the MiddleWares USB_Device drop-down.
    2. Generate the source code with no other changes needed to any USB settings.
    3. In file usbd_cdc_if.c, change #define USB_HS_MAX_PACKET_SIZE from 512 to 256.
    4. In file usbd_cdc.c, change the #define CDC_DATA_HS_MAX_PACKET_SIZE from 512 to 256.

    After doing this, the yellow warning disappeared from Device Manager, and I could receive data at the CDC_Receive_FS function (in usbd_cdc_if.c file) when using PuTTY. Be aware that these definitions return to their incorrect values each time the STM32Cube generates code, and I haven’t found a way around this yet.

    I hope this helps.

提交回复
热议问题