cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX USB CDC Library Problem.

YKim.7
Associate II

MCU : STM32F446RET

CubeMX Version : 4.26.1

===

Hi! I'm currently developing usb CDC(Communication Device Class / USB-OTG-FS) through STM32CubeMX.

​When I upload the automatically generated code without changing any settings, the usb device will not be recognized properly as follows.(Error code 10)

0690X000006BtkfQAC.png

​However, ​following this YouTube video https://youtu.be/oDoavXrQdEg, change the CDC_DATA_HS_MAX_PACKET_SIZE value of usbd_cdc.h file from 512 to 256, and you can see that it is normally recognized.

0690X000006BtkkQAC.png

Is this a problem with the STM32CubeMX library?

Thanks! =)

1 ACCEPTED SOLUTION

Accepted Solutions
YKim.7
Associate II

I found a solution! In the CubeMX Setting, setting heap size over 0x1000 makes usb cdc to work properly.

View solution in original post

3 REPLIES 3
YKim.7
Associate II

I found a solution! In the CubeMX Setting, setting heap size over 0x1000 makes usb cdc to work properly.

Khouloud GARSI
Lead II

Hi @YKim.7​ ,

Correct! When creating your USB CDC application using STM32CubeMX tool, you should take care of increasing the heap size; Otherwise, USB will not be functional (Using Keil for example, the heap size is 0x200 by default which is too low for USB applications). If you increase it to 0x800, the USB device will be successfully enumerated.

Khouloud.

Pavel A.
Evangelist III

Please note: this size belongs to High speed mode, but your USB controller is FS (Full speed). It cannot work in High speed mode so the max. transfer size is limited to 64. How it works for you with larger size? A miracle, perhaps?