Buffer size setting in FX2LP firmware

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi all,

I am using CY7C68013 to design a USB2.0 device. I am confused by the buffer settings in the firmware.

In my firmware, I use EP2 in slave-FIFO bulk-IN mode.

My questions are:

1. The maxPacketSize (payload) for bulk EP2 can only be 512B, right?  If so:

2. When setting EP2CFG, can I use the buffer size of 1024 for bulk EP2? Or I can only use 512 because maxPacketSize=512?

3. When auto-IN mode is used, can I set the EP2AUTOINLEN as 1024 for bulk EP2? Or I can only use 512 because maxPacketSize=512?

pastedImage_0.png

From the endpoint configuration-12, it seems that EP buffer can be set as 1024x4, but I am not sure if this only valid for iso mode. From the technical reference manual and datasheet, I didn't find clear presentation about this.

I set the EP-buffer=512, autoLength=512, the device works. But when multiple devices work simultaneously, some data will lost. So, I am thinking to make full use of the FIFO buffer, like configuration-12, in Bulk EP mode.

Thanks,

Zheng

0 Likes
1 Solution

Hello Zheng,

1. The mentioned setting will not cause any issues. But, the drawback is that the buffer size of 1024bytes is never used completely. Since the EP2AUTOINLEN value is set to 512 bytes, the buffer gets committed to the host once 512 bytes are filled.

2. ISOC transfers do not have a retry mechanism and the FX2LP FIFO buffers are limited to 4kB. Hence, the rate at which the data is received should match the rate at which the data is being sent to the host. When transferring 27MB/s of data, the host can read only 24MB/s which means that there is a data loss of 3MB. Also, this data loss occurs in every micro frame as 303 Bytes accounting to a total of 3MB in 1 second.

If the pixel clock is reduced to 24MHz or lower, the data loss can be avoided.

3. The maximum bandwidth of 24MB/s is for only a particular endpoint. When two devices with separate ISOC endpoints are used, each can get a bandwidth of 24MB/s. But, when the two devices are connected, the host determines if it has got enough bandwidth on the bus to service the two ISOC endpoints. Only, if there is enough bandwidth (depending on other devices connected on the USB bus), the host enumerates the device(s).

Best regards,

Srinath S

View solution in original post

0 Likes
5 Replies
SrinathS_16
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello Zheng,

- maxPacketSize parameter is limited to 512 bytes for a BULK endpoint by the USB 2.0 spec. But, this can be increased to 1024 bytes also but the operation might not be guaranteed on some hosts.

- When maxPacketSize=512, bulk endpoint can be configured for 1024 bytes, 4x buffered (configuration-12 shown in TRM). But, the EP2AUTOINLEN can be set only 512 bytes and not 1024 bytes. This limits the usage of buffer for only 512 bytes. When maxPacketSize=1024 and for same configuration (configuration-12 in TRM), EP2AUTOINLEN can be set to 1024 bytes, thereby making use of complete use of the FX2LP buffers. But, this cannot be guaranteed on all hosts because of the violation of the USB 2.0 specification for maxPacketSize.

So, for guaranteed operation and maximum throughput, 512-byte, BULK, quad buffered endpoint FIFO can be used.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hi Srinath,

Thanks a lot for your clear clarification of the items. To fix my data-loss problem, I am still trying other ideas.

1. What will happen if I set maxPacketSize=512 && bulk-EP buffer=1024x4  &&  EP2AUTOINLEN=512? I tried this "invalid" configuration and it seems that my data-loss problem is alleviated a little. But I am not sure if this will cause other undefined behavior.

2. I am also trying to use ISOC transfer mode in my design, but confused by the bandwidth consideration. The maximum bandwidth for USB2.0 high-speed isoc transfer is 3x1024 B/uframe x 8K uframe/second=24MB/s, for one endpoint.

Is it possible to use this configuration to handle a device with burst datarate=27MB/s but average datarate=15MB/s? For example, in my design, the device is a camera, and the pixel clock is 27MHz in frame valid period, (one byte for one poxel) so the datarate is 27MB/s during frame valid interval. While the total datarate is e.g. 14MB/s. From my understanding, the isoc xfer will get data lost because the fifo buffer (max 4KB) is not enough to buffer an image frame (360960 Bytes) to handle the difference between 27M  burst rate and 24M xfer bandwidth. Is my understanding right?

If I decrease the pixel clock to 24MHz or lower, is it possible to make it work?

3. For isoc transfer, the max bandwidth is 24MB/s. Does this means that the total bandwidth for isoc transfer on this bus is limited to 24MB/s? Or, can we use two devices (2 isoc endpoints in total) to get 24MB/s +24MB/s =48MB/s bandwidth (< 480Mbps)?

Best regards,

Zheng

0 Likes

Hello Zheng,

1. The mentioned setting will not cause any issues. But, the drawback is that the buffer size of 1024bytes is never used completely. Since the EP2AUTOINLEN value is set to 512 bytes, the buffer gets committed to the host once 512 bytes are filled.

2. ISOC transfers do not have a retry mechanism and the FX2LP FIFO buffers are limited to 4kB. Hence, the rate at which the data is received should match the rate at which the data is being sent to the host. When transferring 27MB/s of data, the host can read only 24MB/s which means that there is a data loss of 3MB. Also, this data loss occurs in every micro frame as 303 Bytes accounting to a total of 3MB in 1 second.

If the pixel clock is reduced to 24MHz or lower, the data loss can be avoided.

3. The maximum bandwidth of 24MB/s is for only a particular endpoint. When two devices with separate ISOC endpoints are used, each can get a bandwidth of 24MB/s. But, when the two devices are connected, the host determines if it has got enough bandwidth on the bus to service the two ISOC endpoints. Only, if there is enough bandwidth (depending on other devices connected on the USB bus), the host enumerates the device(s).

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hi Srinath,

Thanks a lot for your clear declaration.

Finally I reduced pix clock to 22MHz to avoid the data loss in ISOC mode. In 24MHz clock rate, it still has a little data lost.

Best regards,

Zheng

0 Likes

Hello Zheng,

The application/driver level overhead can cause these reductions in the data transfer rate.

Best regards,

Srinath S

0 Likes