cancel
Showing results for 
Search instead for 
Did you mean: 

CDC_Transmit_HS does not work when sending exactly 2048 bytes

matic
Associate III
Posted on December 06, 2016 at 20:27

Hi.

I implemented USB HS communication (CDC class) between STMF769 Discovery board (device) and PC (host). It works as expected when I want to send less or more than 2048 bytes. But with 2048 I don't receive anything on the PC side. As said, if Len parameter to CDC_Transmit_HS(uint8_t* Buf, uint16_t Len) function is 2047 or 2049 or anything else, I receive everything. Only when Len is 2048, I don't receive anything.

Any idea? Is this a bug in CDC drivers maybe?

Thanks

#usb-cdc #usb-hs #stm32f7 #usb
4 REPLIES 4
Geoffrey1
Associate III
Posted on December 07, 2016 at 00:11

I think you'll find the same 'problem' with any length that is a multiple of 64.   A transaction is only complete when a partial packet is sent (for HS, less than 64 bytes).  Try following your 2048 byte send by a 0 byte send.  This isn't a flaw of the CDC code per se, although it would have been helpful if it were documented in the Cube code.

Geoffrey

Posted on December 07, 2016 at 00:26

The ZERO LENGTH PACKET thing....   ?

Posted on December 07, 2016 at 07:25

I don't receive anything neither if I

consecutively call:

CDC_Transmit_HS((uint8_t *)Buffer, 2048) ;

CDC_Transmit_HS((uint8_t *)Buffer, 0) ;

nor:

CDC_Transmit_HS((uint8_t *)Buffer, 2048) ;

CDC_Transmit_HS((uint8_t *)Buffer, 2048) ;

But if I call:

CDC_Transmit_HS((uint8_t *)Buffer, 4096) ; I receive all 4096 bytes. So, the theory about multiple of 64 isn't correct...

masoud shahrabi
Associate
Posted on September 14, 2017 at 17:03

Hi obid.matic

I have problem with sending bytes by usb cable at all. I want to use stm32cubemx and when I plug in the cable, my laptop recognizes the virtual com. but hyperterminal can not open the com and I cant send any data. could you send me a sample code to see what is wrong. Sorry for my english. Thanks in advance!