cancel
Showing results for 
Search instead for 
Did you mean: 

I tried to config USB as CDC with STM32CubeMX version 5.0.1 and USB CDC doesn't work.

YAlye
Associate II

Hello,

Controller STM32F302C8T - 48 pins. I tried to config USB as CDC with STM32CubeMX version 5.0.1 and USB CDC doesn't work. STM32CubeMX doesn't setup USB-pins as additional functions or alternative functions. How I can setup USB-pins? And how is correct to setup USB-pins as additional functions or alternative functions?

BR,

 Eugene.

4 REPLIES 4
Pavel A.
Evangelist III

Hi Pavel,

1. Yes, of cause I read this document and a lot of another your documents. But I didn’t find answer for my questions.

DocID025147 Rev 7, Table 13 shows that USB_DM and USB_DP must be initializing as Additional functions. It doesn’t work.

0690X00000882qMQAQ.jpg

2. Also I have question about RAM for USB.

Document AN4879 "USB hardware and PCB guidelines using STM32 MCUs", Table 5 shows that STM32F302x6/8 has 1024 bytes SRAM.

0690X00000882qWQAQ.jpg

But I have access only to 512 bytes.

After I configured USB_DM and USB_DP as alternative functions AF14 and changed defines (for use 512 instead 1024) in stm32f3xx_hal_pcd_ex.h from

0690X00000882qqQAA.jpg

to

0690X00000882rFQAQ.jpg

and in stm32f3xx_hal_pcd_ex.c from

0690X00000882roQAA.jpg

to

0690X00000882s8QAA.jpg

USB CDC began to work OK.

3. Additional STM32CubeMX generates source code for USB CDC with errors, see pictures

0690X00000882sXQAQ.jpg

0690X00000882tQQAQ.jpg

I fix it each time after STM32CubeMX generated source code, it is not comfortable.

My questions:

- your documentations is not correct?

- why STM32CubeMX doesn’t configure USB_DM and USB_DP?

BR,

Eugene.

Pavel A.
Evangelist III

HI Eugene,

It is not "my documentation", I don' t work at ST :)

CubeMX should generate code which configures the USB pins.

If you modified this code for any reason (yes there can be good reasons to do so)

ensure that it compiles without errors and actually runs.

-- pa

YAlye
Associate II

Pavel.

Thank you for your trying to help.

BR,

Eugene.