Data sent from Host over USB is not Committed to GPIF configured as Slave FIFO in FX3 – KBA223338

Version: **

 

Question:

Why are data packets sent from Cypress Control Center/ Custom Host Application not committed to GPIF interface?

 

Answer:

Consider the following scenario for USB 3.0:

 

  • Consider an AUTO DMA channel configured as below:

dmaCfg.size  = 16384;                             //Buffer size is 16KB

dmaCfg.count = CY_FX_SLFIFO_DMA_BUF_COUNT_U_2_P;

dmaCfg.prodSckId = CY_FX_PRODUCER_USB_SOCKET;     //Producer : USB

dmaCfg.consSckId = CY_FX_CONSUMER_PPORT_SOCKET;   //Consumer : GPIF

 

  • In this configuration, the buffer would be committed to GPIF when any of the following conditions are met:
  1. Entire 16 KB buffer is filled by USB.
  2. A partial packet is received from USB (Note: When this happens the amount of data filled in the buffer will not be a multiple of 1024 bytes for USB 3.0 and 512 bytes for USB 2.0).
  3. A zero-length packet is received from USB.

So, design your host application considering these three conditions:

For instance, if OUT transfer needs to be made with X bytes, then:

  1. If X < 16 KB and (X % 1024) != 0, then on completion of X bytes nothing needs to be done.
  2. If X == 16 KB, then on completion of X bytes nothing needs to be done.
  3. If X > 16 KB, then let Y = (X % 16 KB). Now:
    i) If Y == 0, then on completion of X bytes nothing needs to be done.

        ii) If Y < 16 KB and (X % 1024) == 0, then on completion of X bytes, a zero-length packet must be sent so that the buffer in the device gets committed to GPIF.

  • To send a zero length packet, call the XferData() API with ‘len’ parameter set to zero.

  For the usage of XferData(), see the API Guide available in C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\library  after installing FX3-SDK