Can't seem to get data out of DMA

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

cross mob
lock attach
Attachments are accessible only for community members.
ThAl_4704151
Level 4
Level 4
25 sign-ins 25 replies posted 10 replies posted

Hello all,

With some help from the forum, I was able to get the chip to enumerate the other day, and now that that's working, I'm trying to send data through it using DMA to get the data from the host. I've tried to copy the USBBulkLoopManualInOut project.

To configure the endpoint, I:

  1. call CyU3PSetEpConfig()
    1. ep == <endpoint address parsed out of the descriptor, 0x02, 0x04 for output, and 0x86, 0x88 for input
    2. enable = CyTrue
    3. epType = <a type code I parsed out of the descriptor, in this case interrupt>
    4. burstLen = 1
    5. streams = 0
    6. pcktSize = <also parsed out of the descriptor, in this case, either 256 or 512
  2. call CyU3PDmaChannelCreate()
    1. pass in a pointer to a CyU3PDmaChannel in my endpoint struct to keep track of it
    2. CyU3PDmaType_t type is CY_U3P_DMA_TYPE_MANUAL_OUT if the high bit of the endpoint address is 1, and CY_U3P_DMA_TYPE_MANUAL_IN otherwise
    3. if the high bit of the endpoint address is 1, the prodSckId is CY_U3P_UIB_SOCKET_PROD_0 + <the numeric part of the endpoint address, and the consSckId is CY_U3P_CPU_SOCKET_CONS. Otherwise, the prodSckId  is CY_U3P_CPU_SOCKET_PROD and the consSckId is CY_U3P_UIB_SOCKET_CONS_0 + the numeric part of the endpoint address.
    4. dmaMode = CY_U3P_DMA_MODE_BYTE
    5. notification, prodHeader, prodFooter, consHeader, prodAvailCount are all 0
    6. cb is NULL
  3. call CyU3PDmaChannelSetXfer
    1. pass in the same pointer to a CyU3PDmaChannel, and zero for unlimited transfers
  4. call CyU3PUsbFlushEp, passing the address from before. Originally I didn't have this, but I figured it couldn't hurt.

So far so good. Nothing returns an error code.

When I go to get data, I:

  1. call a function I've written to get the CyU3PDmaChannel pointer for the address 2.
    1. Address 2 is supposed to be an endpoint that will allow me to receive data from the host.
    2. I've verified with the debugger that it's returning the same handle out of my endpoint struct for the endpoint address I put in.
  2. I've tried calling CyU3PDmaChannelResume here with that pointer to enable both producer and consumer, but it doesn't seem to do anything.
  3. call CyU3PDmaChannelGetBuffer(<the previously mentioned pointer>, the address of a buffer struct, either CYU3P_WAIT_FOREVER or CYU3P_NO_WAIT)
    1. NO_WAIT returns a timeout immediately, even once I've sent data from the Control Center
    2. WAIT_FOREVER doesn't return at all, even once I've sent data from the Control Center
  4. CyU3PDmaChannelDiscardBuffer to clean up the buffer.

I'll include my source code, but does anyone know what I'm missing, or what I've done wrong?

Thank you for your help!

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hello,

I tried to reproduce the issue at my end and was successful in that. After debugging the firmware I realized that the configureEndpoints() is called just after the CyU3PConnectState API.

configureEndpoints() which is equivalent to CyFxBulkLpApplnStart of the Manual IN OUT example should be called when the CY_U3P_USB_EVENT_SETCONF event occurs. For this USB event call back needs to be registered and events needs to be handled.

********************************************************************

CyU3PUsbRegisterEventCallback(usbEventCallback);

void usbEventCallback(

        CyU3PUsbEventType_t evtype,    /**< The event type. */

        uint16_t            evdata      /**< Event specific data. */

        ){

switch (evtype)

    {

        case CY_U3P_USB_EVENT_SETCONF:

            /* Disable the low power entry to optimize USB throughput */

            CyU3PUsbLPMDisable();

            /* Stop the application before re-starting. */

            if (glIsApplnActive)

            {

            disableendpoint();

            }

            /* Start the loop back function. */

            configureEndpoints ();

            break;

        case CY_U3P_USB_EVENT_RESET:

        case CY_U3P_USB_EVENT_DISCONNECT:

            /* Stop the loop back function. */

            if (glIsApplnActive)

            {

                disableendpoint();  //equivalent to AppStop

            }

            break;

        default:

            break;

    }

***************************************************************

Please find the attached modified firmware and test results. Now, you can try calling the CyU3PDmaChannelGetBuffer as done in the SDK example.

Please let me know if any queries on this

Regards,

Rashi

Regards,
Rashi

View solution in original post

4 Replies