You are here

DMA Buffer problem! | Cypress Semiconductor

DMA Buffer problem!

Summary: 1 Reply, Latest post by Mudabir Kabir on 27 Mar 2014 01:23 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
Albert.Chen's picture
3 posts


I using the slavefifo example,

Here is my DMA setting

    dmaCfg.size  =  (CY_FX_EP_BURST_LENGTH * 1024 * 2) ;

    dmaCfg.count = 1;

    dmaCfg.prodSckId = CY_FX_PRODUCER_USB_SOCKET;


    dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;

    dmaCfg.notification = 0;

    dmaCfg.cb = NULL;

    dmaCfg.prodHeader = 0;

    dmaCfg.prodFooter = 0;

    dmaCfg.consHeader = 0;

    dmaCfg.prodAvailCount = 0;

    apiRetStatus = CyU3PDmaChannelCreate (&glChHandleSlFifoUtoP,

    CY_U3P_DMA_TYPE_AUTO, &dmaCfg);

    if (apiRetStatus != CY_U3P_SUCCESS)





    dmaCfg.consSckId = CY_U3P_CPU_SOCKET_CONS;

    dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT;

    dmaCfg.cb = CyFxBulkSrcSinkDmaCallback;

    apiRetStatus = CyU3PDmaChannelCreate (&glChHandleSlFifoPtoCPU,

    CY_U3P_DMA_TYPE_MANUAL_IN, &dmaCfg);

    if (apiRetStatus != CY_U3P_SUCCESS)




dmaCfg.prodSckId = CY_U3P_CPU_SOCKET_PROD;


dmaCfg.notification = CY_U3P_DMA_CB_CONS_EVENT;

dmaCfg.cb = CyFxBulkSrcSinkDmaCallback;

apiRetStatus = CyU3PDmaChannelCreate (&glChHandleSlFifoCPUtoU,


if (apiRetStatus != CY_U3P_SUCCESS)




I create three dma channel,

1. u2p (bulk_out 2 p port)

 2. p2cpu (p port 2 cpu)

3 cpu2u ( cpu to bulkin)

my fpga will send 16384 byte when i press the button

and it will triggler p2cpu callback, and i will commit data(from fpga ) to cpu2u channel,

In my test, dma buffer must fill with data ( in my setting is 16384 ) and then I can read  the data from bulk_in.

If not , read failed.

I want to know if my fpga just send data which not enough for the dma buffer size and I can send it out.

How can i do that?



Mudabir Kabir's picture
Cypress Employee
44 posts

 Hi Albert,

First of all, If you want to commit data from Pport to USB end, there is no need for 2 channels ( PtoCPU, CPUtoU). Instead you can go for PtoU configured in manual mode. Is there a specific reason why you have opted for 2 different channels?

If you are sending data packet from fpga whose size is less than the DMA buffer size, then it is counted as a short packet.

 A short packet can be committed to the USB host from GPIF end by using the PKTEND# signal in Slave Fifo state machine. The FPGA should be designed to assert the PKTEND# along with the last word of data and SLWR# pulse corresponding to the last word. The FIFOADDR lines must be held constant during the PKTEND# assertion. On assertion of PKTEND# with SLWR#, the GPIF II state machine interprets the packet to be a short packet and commits it to the USB interface. If the protocol does not require any short packets to be transferred, the PKTEND# signal may be pulled high.

Refer Application note AN65974 Designing with the EZ-USB® FX3™ Slave FIFO Interface where this is explained in detail 



Mudabir Kabir

Log in to post new comments.