cancel
Showing results for 
Search instead for 
Did you mean: 

USB_CDC on STM32F0 series

BPR
Associate II

I'm trying USB_CDC FS (Full Speed) on STM32F072C8 Controller. I'm able to Transmit data larger than 64 bytes to PC, but not able to receive data more than 64 bytes.

I'm using CDC_Receive_FS function for receiving and buffer size is 1000.

If i send 100 bytes from PC to STM32 , i receive only 64 bytes.

Does anybody have an example code on this....?

6 REPLIES 6
BPR
Associate II

Thank you Mon2.....

but is there any way that i can implement it in the code generated by STMCubeMX....?

Mon2
Senior III

Please review the following webpage and test again using the 64 byte recommendation for the EP definition:

https://damogranlabs.com/2018/02/stm32-usb-cdc/

A complete project file is posted on the landing page.

0690X000006DpVFQA0.png

0690X000006DpVKQA0.png

Please post your update after testing.

BPR
Associate II

Actually i'm using the same configuration as showed in this site, but it is not working..

Hi. Please review the following thread,

https://stackoverflow.com/questions/33549084/stm32cubemx-usb-cdc-vcp

and special notes:

0690X000006Dr7AQAS.png

Please post your update after this review. If you have done all of these required steps, please post your project / code with details of how you are testing. Include the terminal program being used or whatever to send data to this USB CDC device.

If I understand correctly, this widget is able to transmit 100 bytes in a burst but unable to receive > 64 bytes in a burst? Sounds like a buffer and/or flow control issue with the UART side but from my basic knowledge, USB CDC does not offer flow control lines (by default). However they could be implemented. Have seen some finished USB UARTs (CDC type) that offer flow control lines (RTS/CTS). Believe this is from Silabs or Exar (Maxlinear).

Your code should be ok to work with the STM32F072 Discovery kit?

BTW - Have you attempted to test the idea using MBED? (only to verify the concept and tool setup)

But post the project to see where this goes in the review..

BPR
Associate II

Hi, I tried reducing the MAX_Packet_Size from 64 to 32. Now i receive only 32 bytes.

I'm just trying to achieve USB VCP communication to implement it in my project.

I'm using the code straight away generated by STMCubeMX with no modifications, Initially i hard coded some message of 400 bytes to Transmit using CDC_Transmit_FS() function it was working. Now i'm just trying to Transmit what ever i Receive from CDC_Receive_FS().

RealTerm tool is being used to send and receive data.

Please have a look on below images...

Case 1

0690X000006DsSYQA0.jpg

After reset i sent "Hello" to Device and it printed some Null characters after Hello.

Case 2

0690X000006DsSdQAK.jpg

Sent "This is a test message "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" containing more than 64 Bytes" and it printed only 64 bytes with some Null characters after message.

Case 3

0690X000006DsSsQAK.jpg

Again i sent "Hello" text but this time it printed Hello with part of previous message.

"BTW - Have you attempted to test the idea using MBED? (only to verify the concept and tool setup)" - I'm new to ARM controllers so i'm unaware of MBED concept.

I've attached my Test Project please review and let me now if i'm doing anything wrong or missing something.

Thank You.....