cancel
Showing results for 
Search instead for 
Did you mean: 

USB VCP Bug?

rNabi
Associate II

Hi .I use CDC to transmit data to computer .

I want to transmit big array to the computer using CDC_Transmit_FS

what is the maximum buffer length that support this function ?

this is my code:

CDC_Transmit_FS((uint8_t *)buffer,(uint16_t)73728);

but some amount of data lost in the computer.

6 REPLIES 6
Tobias Wedell
Associate II

Hi,

When you cast to uint16 then the highest value is 2^16=65536.

I don't know if the function support a length value of uint32. If not you must split your array.​

Confusing a limitation of the API with a bug.

>> If not you must split your array.​

Indeed, going to need to iterate through the array breaking into pieces which fit through the interface.

>>(uint16_t)73728

That's never going to be viable, and going to fail in any/all applications of such a cast.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rNabi
Associate II

Hi thanks for your response

in usbd_cdc.h

typedef struct

{

 uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE/4];     /* Force 32bits alignment */

 uint8_t CmdOpCode;

 uint8_t CmdLength;   

 uint8_t *RxBuffer; 

 uint8_t *TxBuffer;  

 uint32_t RxLength;

 uint32_t TxLength;   

 __IO uint32_t TxState;    

 __IO uint32_t RxState;   

}

USBD_CDC_HandleTypeDef;

Tx lenght is 32 bits so do you think I can change

USBD_CDC_SetTxBuffer

CDC_Transmit_FS

input functions to uint32_t Len?

Pavel A.
Evangelist III

> so do you think I can change USBD_CDC_SetTxBuffer CDC_Transmit_FS  

input functions to uint32_t Len?

You do not want to tinker with USBD_CDC_SetTxBuffer because it is part of the library maintained by ST.

CDC_Transmit_FS is OK to modify, it is part of your code (generated from a template, though). For example, you can a do a loop there.

-- pa

Ben K
Senior III

This question is also dependent on your target. If you are using a chip with OTG cores, the maximum length is limited by the peripheral, but on chips with normal USB the length is software limited only.

rNabi
Associate II

Yes I test on stm32f4discovery with 32 bit length not worked I must split array.

it has OTG cores .