Author Topic: Low bandwidth problem using CYUSB driver and Windows  (Read 6630 times)

shasta mcnasty

  • Member
  • ***
  • Posts: 3
Low bandwidth problem using CYUSB driver and Windows
« on: October 21, 2010, 09:23:08 pm »
I am using the Cypress CY7C68013A chip to interface an FPGA to a Windows host PC.

The FPGA has various modes of operation, it is capable of generating variable sized data blocks at unpredictable rates.  However, right now it's running in a simple mode, which generates fixed-size (~40K byte) blocks at a constant (but programmable) rate.  The FPGA data comes from a FIFO.  

I am using bulk IN 512-byte packet transfers to get the data from the FPGA to the host PC.  Currently, I can only transfer packets error-free if I set the constant rate to ~8 Hz (~3.84 Mbits/sec).  My target data rate in this mode is ~100-200 Hz (32-64 Mbits/sec).  Yes I am using a high-speed endpoint!  

I am using a USB protocol analyzer (Ellisys USB200) to monitor the transfers.  When I look in detail at the packets, I see:

Frame n: a single 512-byte IN transfer (IN, DATA, ACK)
Frame n+1: empty
Frame n+2: empty
Frame n+3: empty
Frame n+4: another single 512-byte IN transfer

Note that sometimes I see 4 or 5 empty frames between IN transfers, but never fewer than 3.  Each frame is of course 125 us long, so I am transferring a single 512-byte packet every 500-750 us.  

In order to (barely) achieve my minimum acceptable 32 Mbit/sec rate, I need to have one 512-byte IN packet in each frame (with no empty frames).  Ideally I would like to achieve a higher rate by having multiple packets per frame.  

I am confident that the bottleneck is not on the FPGA (data generation) side.  The FPGA generates 16-bit data at a constant rate of 10 MHz.  So it only takes 25.6 us to generate 512 bytes of data.  

It seems that the host PC software is not efficiently pulling these IN packets from the CY7C68013A chip--it's not requesting IN packets at a high enough rate.  The software is using the Cypress CYUSB driver (I didn't write the software, but do have access to the source code and the programmer).  

Any suggestions for where the programmer and I should look to find performance improvements?  

PS I do have USB Complete, there is no way I could have gotten as far as I have in this application without it!  
« Last Edit: October 21, 2010, 09:46:58 pm by shasta mcnasty »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3005
    • Lakeview Research
Re: Low bandwidth problem using CYUSB driver and Windows
« Reply #1 on: October 21, 2010, 09:49:24 pm »
If the host application is requesting only 512 bytes in each API call, increase the transfer size. This won't affect the size of the transactions/packets but will allow the host controller to schedule transfers more efficiently.

Jan

shasta mcnasty

  • Member
  • ***
  • Posts: 3
Re: Low bandwidth problem using CYUSB driver and Windows
« Reply #2 on: October 21, 2010, 10:34:44 pm »
Thanks for the suggestion!  I'll talk with the programmer tomorrow about the transfer size.  I'm not sure how he's doing it right now. 

shasta mcnasty

  • Member
  • ***
  • Posts: 3
Re: Low bandwidth problem using CYUSB driver and Windows
« Reply #3 on: October 22, 2010, 10:36:36 am »
Just a followup, the programmer switched from "synchronous" data transfer (I think using the CYUSB API XferData() function) to "asynchronous" data transfer (I think using the BeginDataXfer() and FinishDataXfer() functions).  That brought our effective bandwidth up significantly...we are getting multiple packets per frame, with fewer empty frames. 

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3005
    • Lakeview Research
Re: Low bandwidth problem using CYUSB driver and Windows
« Reply #4 on: October 22, 2010, 02:15:07 pm »
Glad you got it working. Thanks for posting the solution.

Jan