You are here

FX3 - DMA Override mode and ZLP | Cypress Semiconductor

FX3 - DMA Override mode and ZLP

Summary: 2 Replies, Latest post by Stan on 09 Nov 2016 09:07 AM PST
Verified Answers: 0
Last post
Log in to post new comments.
sbertrand_1682031's picture
User
13 posts

Hi,

Testing communication between a WinUSB Host Application and the FX3, I am confronted to max packet length and zero length packet handling.

On the host application, I need to check is the buffer i am sending is multiple of the max packet length and send an empty buffer to the API to generate a ZLP.

On the FX3, I have tested the DMA Manual channel. I am now trying to transfer data in override mode. My buffer size is a multiple of the max packet size. Multiple transaction occurs to transfer the buffer. I am missing the ZLP at the end to complete the transfer. I have tried to set the CY_U3P_DMA_BUFFER_EOP flag but I don't have the ZLP. My WinUSB application hangs and my USB analyzer has a hard time grouping the transaction into correct transfer due to the missing ZLP.

I believe that I could do another CyU3PDmaChannelSetupSendBuffer call with a zero length buffer. However I wish not to wait for the completion of the first call in order to send the ZLP as I handle completion asynchronously with the DMA callback.

A good understanding of DMA constrain will allow me to design a suitable spec. Making my max buffer size more than an exact multiple of the max packet size could help avoid ZLP.

Regards,
Stan

nisa's picture
Cypress Employee
86 posts

What is your FX3 application ? Is it in slave fifo mode? If so, you can refer the GPIF project of AN65974. When the data is a multiple of packet size, then the host will not know if data from the device has ended. So, the last Xfer will fail and the last some data may be lost. to avoid this, as per the USB protocol, you need to send a ZLP. In the GPIf project you will notice how we are sending a ZLP. Doing a commit without in_data, there will be a ZLP at the end. If there is a commit with In_data, then there wont be any ZLP. CyU3PDmaChannelSetupSendBuffer will not send ZLP by itself. You can also try by making the DMA buffer size o 1024 (i.e. packet size), if this does not hamper the performance of the device

sbertrand_1682031's picture
User
13 posts

Thank you for your answer, I will review closely the AN65974 project.

For now my FX3 application is USB only with data coming from the CPU. Later it will be using the GPIF interface.

Something still puzzles me :
- With DMA : when the data is 2048 and a zlp is received, the dma buffer is passed to the USB consumer socket ( doing a DMA Loopback between 2 USB EP). In that case the DMA buffer size is 2048 and the USB IN EP will issue a ZLP.

- With CyU3PDmaChannelSetupSendBuffer  : I should be able to obtain a similar behavior. How do I setup my buffer in order to have 2048 data and have the IN EP generate a ZLP. It would seems that CY_U3P_DMA_BUFFER_EOP  would be the right option passed in the DMA buffer status. Is there a difference between count and size ? CyU3PDmaChannelSetupSendBuffer doesn't use the size field.

Maybe I am missing something.

Log in to post new comments.