Learn how to optimise USB-C for your designs at 18 May's USB-C PD Webinar.
Click here to register.

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

Level 1
Level 1
5 sign-ins First question asked First like given

Hi, I have a problem with the transmission between the FPGA, the FX3 and the PC.

In my project I have to transmit data from the FPGA to the PC with a random data rate, it could be between 1MHz and 100MHz. (4MB/sec to 400MB/sec)


My system is designed as follow:

- FPGA: I have a self made IP core used to interface with the GPIF II peripheral of the FX3.

- FX3: the GPIF II is in "synch slave fifo" mode, with 2 bits of address, 32 bit data bus, FLAG_A (normal) and FLAG_B (partial) dedicated to thread_0 for the transmission (FPGA -> FX3), FLAG_C (normal) and FLAG_D (partial) dedicated to thread_1 for the reception (FX3 -> FPGA). The DMA is configured with 2 sockets (GPIF -> USB, USB -> GPIF) mapped to thread 0 and 1 respectively, both with 4 buffer of 16kB each. DMA is in AUTO mode.

- HOST APP: for the transmission (FPGA -> PC) I simply call the function "USBDevice->BulkInEndPt->XferData(buffer_in, length_buffer_in)" in a sort of infinite while loop. 


The problem is that if I try to send 4 bytes per each clock cycle with the FPGA I can easily reach 320MB/sec without any kind of errors (which is great, it should have been 400MB/sec but considering the overhead it dropped to 320MB/sec), but if I try to send 4 bytes every 16 clock cycles (100MHz/16 = 6.25MHz = 25MB/sec) it doesn't work.

In order to reach 320MB/sec I used "length_buffer_in" = 1966080 (16kB x 120, so that the function XferData does not return before filling 120 times the DMA buffers).

I discovered that if I reduce "length_buffer_in" to 1024 the system (4 bytes every 16 clock cycles) works properly and it transmit data at 15MB/sec, but if I put "length_buffer_in" to 2048 it doesn't work anymore; the point is that the function XferData returns with timeout error caused by the fact that I am not sending data, but I am not sending data because both FLAG_A and FLAG_B are low (they indicate "dma_buffer_full").

I also tried to send 4 bytes every 8 clock cycles (50MB/sec). If I use length_buffer_in = 1024 it works at 15MB/sec, if length_buffer_in = 2048 it works at 30MB/sec, if length_buffer_in = 4096 it works at 45MB/sec, if length_buffer_in = 8192 it doesn't work (same problem, flags stay low and so I cannot write anymore to the FX3 that causes the timeout error).

If i try to send data at 100MHz (400MB/sec) or 50MHz (200MB/sec) it always work, also with length_buffer_in = 1966080, at 320MB/sec or 160MB/sec respectively.

I cannot understand which is the problem and why I cannot write slowly. Maybe the problem is that I cannot fill DMA buffers slower that the emptying rate from the USB side? Maybe should I write at 10MHz in a FIFO and then emptying  the FIFO through the GPIF at 100MHz once in a while (in this way when I am in transmission phase I can transmit data at 400MB/sec, and once the FIFO is empty I go in IDLE state)?


Could you please help me?

Thank you very much


1 Reply
First like given 250 sign-ins 50 solutions authored

Hello Lucac,

- Can you please provide the timing for both cases 400MB/sec & 25MB/sec we are not clear about this?
- I like to share with you some previous questions related to your case please refer to them and let us know if you need more help.

- You can try to use length_buffer_in as 1024 in case of 400MB/Sec case and let us know what data rate are you getting.

Best Regards,