CY_U3P_ERROR_MEMORY_ERROR

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

cross mob
Anonymous
Not applicable

I am working on a video capture card based on the GPIFII to image sensor (AN75779) document and examples. I have my own board with an FX3 on it. I am using SDK V1.2.

   

When I set the MultiChannel DMA to have a size of 1024 and a count of 16 I get the CY_U3P_ERROR_MEMORY_ERROR error when I call CyU3PDmaMultiChannelCreate. If I set the count to 10 the call is successful. I know the document says to use the fx3.ld file that comes with the project and I am but I still get the error. I see that there are several changes in the fx3.ld file that comes with the SDK V1.2. What can I do to make this work?

0 Likes
3 Replies
Anonymous
Not applicable

What is the total size of the buffer that you are trying to create.

   

You should be able to create total size of around 252KB buffer for your DMA channel.

0 Likes
Anonymous
Not applicable

Thank you sai krishna,

   

I think I have figured this out. I was wrong about the settings I had in the post. I have created an endpoint that has a size of 1024 and a burst of 16. Then I created a Multi Channel DMA with a size of 16K and a count of 8. That is what was failing. I changed the count to 6 and now it works. I think the reason I can not allocate 8 DMA buffers is because I have other endpoints and DMA channels that use memory. Does that make sense?

   

Here is some of my code:

   

/* UVC Video Streaming Endpoint Packet Size */
#define CY_FX_EP_BULK_VIDEO_PKT_SIZE            0x400          // 1024 Bytes

/* UVC Video Streaming Endpoint Packet Count */
#define CY_FX_EP_BULK_VIDEO_PKTS_COUNT          16

// UVC Buffer size - Will map to BULK Transaction size
#define CY_FX_UVC_STREAM_BUF_SIZE                  (CY_FX_EP_BULK_VIDEO_PKTS_COUNT * CY_FX_EP_BULK_VIDEO_PKT_SIZE)       // 16K
#define CY_FX_USB_EP_PKT_SIZE                    32                            // USB Endpoint Max packet size
#define CY_FX_USB_DMA_BUF_SIZE                   32                            // USB FW channel buffer size
#define CY_FX_USB_DMA_BUF_COUNT                  1                           // USB FW channel buffer count
 

   

    // Set the Endpoint Configurations
    // Producer Endpoint configuration
    endPointConfig.enable = 1;
    endPointConfig.epType = CY_U3P_USB_EP_BULK;
    endPointConfig.pcktSize = CY_FX_USB_EP_PKT_SIZE;
    //endPointConfig.isoPkts = 1;
    endPointConfig.burstLen = 1;
    endPointConfig.streams = 0;

    // Configure the Endpoint
    apiRetStatus = CyU3PSetEpConfig(CY_FX_EP_PRODUCER, &endPointConfig);
    if (apiRetStatus != CY_U3P_SUCCESS)
        CyFxAppErrorHandler(apiRetStatus);

    // Consumer Endpoint configuration
    endPointConfig.enable = 1;
    endPointConfig.epType = CY_U3P_USB_EP_BULK;
    endPointConfig.pcktSize = CY_FX_USB_EP_PKT_SIZE;
    //endPointConfig.isoPkts = 1;
    endPointConfig.burstLen = 1;
    endPointConfig.streams = 0;

    // Configure the Endpoint
    apiRetStatus = CyU3PSetEpConfig(CY_FX_EP_CONSUMER, &endPointConfig);
    if (apiRetStatus != CY_U3P_SUCCESS)
        CyFxAppErrorHandler(apiRetStatus);

    // Consumer Endpoint 2 configuration
    endPointConfig.enable = 1;
    endPointConfig.epType = CY_U3P_USB_EP_BULK;
    endPointConfig.pcktSize = CY_FX_EP_BULK_VIDEO_PKT_SIZE;
    endPointConfig.isoPkts = 1;
    endPointConfig.burstLen = CY_FX_EP_BULK_VIDEO_PKTS_COUNT;
    endPointConfig.streams = 0;

    // Configure the Endpoint
    apiRetStatus = CyU3PSetEpConfig(CY_FX_EP_BULK_VIDEO, &endPointConfig);
    if (apiRetStatus != CY_U3P_SUCCESS)
        CyFxAppErrorHandler(apiRetStatus);

    // Create a DMA Manual IN channel between USB Producer socket and the CPU
    dmaUsbConfig.size = CY_FX_USB_DMA_BUF_SIZE;
    dmaUsbConfig.count = CY_FX_USB_DMA_BUF_COUNT;
    dmaUsbConfig.prodSckId = CY_FX_EP_PRODUCER_SOCKET;
    dmaUsbConfig.consSckId = CY_U3P_CPU_SOCKET_CONS;
    dmaUsbConfig.dmaMode = CY_U3P_DMA_MODE_BYTE;
    dmaUsbConfig.notification = CY_U3P_DMA_CB_PROD_EVENT;
    dmaUsbConfig.cb = CyFxUsbDmaCallback;
    //dmaUsbConfig.cb = NULL;
    dmaUsbConfig.prodHeader = 0;
    dmaUsbConfig.prodFooter = 0;
    dmaUsbConfig.consHeader = 0;
    dmaUsbConfig.prodAvailCount = 0;

    // Create the channel
    apiRetStatus = CyU3PDmaChannelCreate (&glChHandleUsb2Fw, CY_U3P_DMA_TYPE_MANUAL_IN, &dmaUsbConfig);
    if (apiRetStatus != CY_U3P_SUCCESS)
        CyFxAppErrorHandler(apiRetStatus);

    // Create a DMA Manual OUT channel between CPU and USB consumer socket
    dmaUsbConfig.size = CY_FX_USB_DMA_BUF_SIZE;
    dmaUsbConfig.count = CY_FX_USB_DMA_BUF_COUNT;
    dmaUsbConfig.prodSckId = CY_U3P_CPU_SOCKET_PROD;
    dmaUsbConfig.consSckId = CY_FX_EP_CONSUMER_SOCKET;
    dmaUsbConfig.dmaMode = CY_U3P_DMA_MODE_BYTE;
    dmaUsbConfig.notification = CY_U3P_DMA_CB_CONS_EVENT;
    dmaUsbConfig.cb = NULL;
    dmaUsbConfig.prodHeader = 0;
    dmaUsbConfig.prodFooter = 0;
    dmaUsbConfig.consHeader = 0;
    dmaUsbConfig.prodAvailCount = 0;

    // Create the channel
    apiRetStatus = CyU3PDmaChannelCreate (&glChHandleFw2Usb, CY_U3P_DMA_TYPE_MANUAL_OUT, &dmaUsbConfig);
    if (apiRetStatus != CY_U3P_SUCCESS)
        CyFxAppErrorHandler(apiRetStatus);
   
        // Create a DMA Manual OUT channel between CPU and USB consumer socket
    dmaMultiConfig.size = CY_FX_UVC_STREAM_BUF_SIZE;
    dmaMultiConfig.count = 6; //CY_FX_USB_DMA_BUF_COUNT;
    dmaMultiConfig.validSckCount = 2;
    dmaMultiConfig.prodSckId [0] = (CyU3PDmaSocketId_t)CY_U3P_PIB_SOCKET_0;
    dmaMultiConfig.prodSckId [1] = (CyU3PDmaSocketId_t)CY_U3P_PIB_SOCKET_1;
    dmaMultiConfig.consSckId [0] = (CyU3PDmaSocketId_t)CY_FX_EP_CONSUMER3_SOCKET;
    dmaMultiConfig.prodAvailCount = 0;
    dmaMultiConfig.prodHeader = 0;
    dmaMultiConfig.prodFooter = 0;
    dmaMultiConfig.consHeader = 0;
    dmaMultiConfig.dmaMode = CY_U3P_DMA_MODE_BYTE;
    dmaMultiConfig.notification =  CY_U3P_DMA_CB_PROD_EVENT | CY_U3P_DMA_CB_CONS_EVENT;
    dmaMultiConfig.cb = CyFxDMACallback;

    // Create the channel
    apiRetStatus = CyU3PDmaMultiChannelCreate (&glChHandleUVCStream, CY_U3P_DMA_TYPE_MANUAL_MANY_TO_ONE , &dmaMultiConfig);
    if (apiRetStatus != CY_U3P_SUCCESS)
        CyFxAppErrorHandler(apiRetStatus);
 

0 Likes
Anonymous
Not applicable

Yes Garyio, your understanding is right.

   

Regards,

   

sai krishna.

0 Likes