cancel
Showing results for 
Search instead for 
Did you mean: 

Is it Possible for multiple IN bulk endpoints in CDC ?

connectjagadeep
Associate II
Posted on March 08, 2016 at 17:58

Hi, 

    I have prepared an SDK from Cube for CDC FS device with one endpoint for data IN  and one endpoint for data OUT. It works well as expected but with slightly less data rate than anticipated. I can increase HCLK to raise the data rate but it causes problems in other modules. So I though about increasing IN endpoint from 1 to 2 or 3 to achieve faster data rate and failed to get it work. I have successfully configured the device and PC can detect a VCP, but can not transmit data. So, before I spend anytime in further investigation I would like to know following things:

1) Is it possible to have more than one IN bulk data endpoints for CDC FS ?

2) If so, will there be an increase in the data rate while using two/more endpoints ?

Regards,

Jagadeep. 

#usb #cube #usb #usb #cdc #cdc #cdc #endpoints #endpoint
7 REPLIES 7
Walid FTITI_O
Senior II
Posted on March 10, 2016 at 18:47

Hi ram.jagadeep,

Yes you can have more than one In Bulk data endpoint, and the number of total endpoints depends of the device you are using ( check relevant datasheet).

What is the STM32 device you are using ?

-Hannibal-

tsuneo
Senior
Posted on March 11, 2016 at 10:19

> 1) Is it possible to have more than one IN bulk data endpoints for CDC FS ?

USB CDC spec allow no more than one IN endpoint at single Communication Data class interface.

3.4.2 Data Class Endpoint Requirements (usbcdc11.pdf, p12)

 

The type of endpoints belonging to a Data Class interface are restricted to being either isochronous or bulk, and are expected to exist in pairs of the same type (one In and one Out).

 

 

3.5.2 Data Class Endpoint Requirement (CDC120.pdf, p9)

 

The type of endpoints belonging to a Data Class interface are restricted to being either isochronous or bulk, and are expected to exist in pairs of the same type (one In and one Out).

 

You may have more than one bulk IN EP using multiple CDC interfaces, ie. composite device (CDC + CDC)

> 2) If so, will there be an increase in the data rate while using two/more endpoints ?

Because of complexity of composite CDC interfaces, I don't recommend this way.

In most cases, greater ''transfer'' (buffer) size improves your transfer speed. The transfer speed is proportional to the buffer size, for example, 500 bytes buffer - 500 kbytes/sec

Your data is packed into the large buffer once. When the buffer goes full, the entire buffer is passed to the bulk IN endpoint at a time. While the buffer is sent to host, your firmware packs data into another buffer. When the second buffer is full, this buffer is passed to the bulk IN endpoint, and back to the top.

The buffer size is chosen so that it isn't a multiple of 64 bytes.

If you would choose a multiple of 64, the firmware should send ZLP (Zero-Length Packet) after the buffer transfer, to terminate the transfer.

Tsuneo 

connectjagadeep
Associate II
Posted on March 11, 2016 at 10:32

Thank you Hannibal, I use STM32F7-Discovery.

tsuneo
Senior
Posted on March 11, 2016 at 14:21

Sorry, comment for another topic has wrongly posted to this topic.

Tsuneo

Walid FTITI_O
Senior II
Posted on March 16, 2016 at 16:33

Hi ram.jagadeep, 

Using more than one endpoint has no relation with  increasing the data rate.

To increase the data rate, try to use the double buffer. 

-Hannibal-

connectjagadeep
Associate II
Posted on March 17, 2016 at 16:02

- To increase the data rate, try to use the double buffer. 

 

Could you please let me know what you mean by double buffer.

Is the endpoint size ? If so, I already have to the maximum size (64 B for full speed)

or is the data buffer of application firmware to be doubled ? I observed that it is only possible to send 64B in one send function (CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)). Here the maximum value of the Len parameter is 64B, more than that leads to communication failure. So, it doesn't make difference in the data rate.

/Jagadeep

tsuneo
Senior
Posted on March 22, 2016 at 02:13

> Is the endpoint size ? If so, I already have to the maximum size (64 B for full speed) or is the data buffer of application firmware to be doubled ?

In USB sense, ''double buffer'' means that the endpoint hardware is able to keep two or more ''transaction'' request from firmware. Double buffer is applied just to the ''Device-only'' USB engine on F0, F103, F3, L0 and L1. OTG_FS and OTG_HS engines may have greater FIFO than single transaction. But it doesn't mean ''double buffer'', because these engines are designed to handle single ''transfer'' of multiple transactions.

Anyway, the USB device stack of Cube hides this difference: CDC_Transmit_FS() issues ''transfer'' request, which may be greater than transaction size (64 bytes). ''Len'' parameter means the transfer size.

> I observed that it is only possible to send 64B in one send function (CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)). Here the maximum value of the Len parameter is 64B, more than that leads to communication failure.

What do you mean ''communication failure''?

Another call of CDC_Transmit_FS() blocks execution, until the last transfer finishes. It is supposed behavior. If you wouldn't like this behavior, check (hcdc->TxState == 0) before calling another CDC_Transmit_FS()

Tsuneo