2 Replies Latest reply on May 30, 2012 2:49 AM by laim.maskey

    Extra fields of CyU3PDmaChannel

    laim.maskey

      Hi,

         

      The CyU3PDmaChannel structure has a lot of extra fields that are not configured when a CyU3PDmaChannel is created. The code below shows a typical CyU3PDmaChannel setup

         

      dmaCfg.size = bulksize;
                  dmaCfg.count = CY_FX_SLFIFO_DMA_BUF_COUNT;
                  dmaCfg.prodSckId = (CyU3PDmaSocketId_t)(CY_U3P_UIB_SOCKET_PROD_0 | CY_FX_EP_PRODUCER_SOCKET);
                  dmaCfg.consSckId = (CyU3PDmaSocketId_t)(CY_FX_EP_CONSUMER_PPORT_SOCKET);
                  dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;
                  dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT;
                  dmaCfg.cb = CyFxSlFifoUtoPDmaCallback;
                  dmaCfg.prodHeader = 0;
                  dmaCfg.prodFooter = 0;
                  dmaCfg.consHeader = 0;
                  dmaCfg.prodAvailCount = 0;

         

      But there are a lot more parts to this structure than shown above . For example according to the FX3APIGuide there are two fields called currentProdIndex and currentConsIndex which point to the descriptor of the active DMA buffer.

         

      Can I read the value of these two fields to find out more information about the status of the DMA buffers? I have tried reading these but they don't change during DMA transfers. What I hope to do with this information is determine whether a DMA buffer is empty or full. If anyone else has a way of doing this I would be grateful to find out how.

      Sodafarl

        • 1. Re: Extra fields of CyU3PDmaChannel
          steve.magnani

          If you have a JTAG debugger you can look at the DMA descriptors directly; they are located at 0x40000000. Header files cyu3descriptor.h and sock_regs.h describe the format; each descriptor is 16 bytes. I look at the 'sync' field to find the descriptors I'm interested in, then the 'size' field to find the current status (low few bits; see sock_regs.h).

          Also I believe that for the GPIF block, the current in-progress descriptor index for socket 0 is stored at 0xE0018000. See CY_U3P_PIB_SCK_DSCR_ADDRESS in pib_regs.h.

          Hope this helps,
          Steve

          • 2. Re: Extra fields of CyU3PDmaChannel
            laim.maskey

            Thanks Steve, I was able to use your suggestions to make progress with this. I used the CyU3PDmaDscrGetConfig function to get the buffers descriptor  and then looked at the size variable from this  to see if the buffer was full or empty - CY_U3P_BUFFER_OCCUPIED. I can use this to signal to the host computer that data is available for transfer.

               

            Once again many thanks.

               

            Sodafarl