FX3S example applications questions DMA reset

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

cross mob
SaMe_4645651
Level 1
Level 1

Hello everyone,


i have two questions regarding the application examples for the Cypress FX3S.

The first question is for the FX3SMassStorage example, CyFxMscApplnSibCB function:

In the same function, two kind of errors are managed by resetting the DMA Channels. But glCmdDirection is used to reset different channels:

First case:

    if (evt == CY_U3P_SIB_EVENT_XFER_CPLT)

    {

        if (status != CY_U3P_SUCCESS)

        {

            glMscCmdStatus     = 1;

            glSensePtr[portId] = CY_FX_MSC_SENSE_CRC_ERROR;

            /* Transfer has failed. Reset the DMA channel. */

            if (glCmdDirection)

            {

                CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_CONS_0 | CY_FX_MSC_EP_BULK_IN_SOCKET),

                        &sockConf);

                glMscResidue -= sockConf.xferCount;

                CyU3PDmaChannelReset (&glChHandleMscIn);    // <-- resets the bulk_in channel

            }

            else

            {

                CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_PROD_0 + CY_FX_MSC_EP_BULK_OUT_SOCKET),

                        &sockConf);

                glMscResidue -= sockConf.xferCount;

                CyU3PDmaChannelReset (&glChHandleMscOut);   // <-- resets the bulk_out channel

            }

        }

   }

Second case:

    if ((evt == CY_U3P_SIB_EVENT_DATA_ERROR) || (evt == CY_U3P_SIB_EVENT_ABORT))

    {

        /* Transfer has failed. Reset the DMA channel. */

        if (glCmdDirection)

        {

            CyU3PDmaChannelReset ((CyU3PDmaChannel *) &glChHandleMscOut); // <-- resets the bulk_out channel

        }

        else

        {

            CyU3PDmaChannelReset ((CyU3PDmaChannel *) &glChHandleMscIn);  // <-- resets the bulk_in channel

        }

        /* Make sure the request is aborted and that the controller is reset. */

        CyU3PSibAbortRequest (portId);

    }

Why is it different?

---------------

Second question, regarding the RAID1 application note example (AN89661):

Analyzing the content of the CyFxMscApplnSibCB function, I have found different behavior on error conditions:

if (evt == CY_U3P_SIB_EVENT_XFER_CPLT) {

    glSPortPending &= ~(1 << portId);

    if (status != CY_U3P_SUCCESS) {

     

...

      /* Transfer has failed. Reset the DMA channel. */

      if (glCmdDirection) {

        CyU3PDmaSocketGetConfig((uint16_t)(CY_U3P_UIB_SOCKET_CONS_0 | CY_FX_MSC_EP_BULK_IN_SOCKET), &sockConf);

        glMscResidue -= sockConf.xferCount;

        if (glRaidMultiChannelValid)

          CyU3PDmaMultiChannelReset((CyU3PDmaMultiChannel *)&glChHandleUSBOut);

        else

          CyU3PDmaChannelReset(&glChHandleWrErrIn);

      } else {

        CyU3PDmaSocketGetConfig((uint16_t)(CY_U3P_UIB_SOCKET_PROD_0 + CY_FX_MSC_EP_BULK_OUT_SOCKET), &sockConf);

        glMscResidue -= sockConf.xferCount;

        CyU3PDmaMultiChannelReset(&glChHandleUSBOut);

      }

    }

Regardless of glCmdDirection, the glChHandleUSBOut is reset. This example differs from FX3SMassStorage (the first code excerpt). Could this be a bug?

I hope this post is clear enough. Thanks in advance for you time!
Salvatore.

0 Likes
1 Solution
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello Salvatore,

Thank you for bringing the error to our notice.

I have reported this error to respective team and the error would be fixed in the next sdk (FX3SMassStorage example firmware ) release.

As for now, you can swap the two DMA channel reset under CY_U3P_SIB_EVENT_DATA_ERROR or  CY_U3P_SIB_EVENT_ABORT

  if ((evt == CY_U3P_SIB_EVENT_DATA_ERROR) || (evt == CY_U3P_SIB_EVENT_ABORT))

    {

        /* Transfer has failed. Reset the DMA channel. */

        if (glCmdDirection)

        {

            CyU3PDmaChannelReset ((CyU3PDmaChannel *) &glChHandleMscIn);

        }

        else

        {

            CyU3PDmaChannelReset ((CyU3PDmaChannel *) &glChHandleMscOut);

        }

EDITED:

The same changes need to be done for RAID1 application note example (AN89661):

if (evt == CY_U3P_SIB_EVENT_XFER_CPLT)

.

.

if (glCmdDirection)

     {

CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_CONS_0 | CY_FX_MSC_EP_BULK_IN_SOCKET),

&sockConf);

glMscResidue -= sockConf.xferCount;

     CyU3PDmaMultiChannelReset ((CyU3PDmaMultiChannel *) &glChHandleUSBIn);

}

     else

     {

   CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_PROD_0 + CY_FX_MSC_EP_BULK_OUT_SOCKET),

&sockConf);

   glMscResidue -= sockConf.xferCount;

    if (glRaidMultiChannelValid)

     CyU3PDmaMultiChannelReset ((CyU3PDmaMultiChannel *) &glChHandleUSBOut);

     else

     CyU3PDmaChannelReset (&glChHandleWrErrIn);

     }

Regards,

Rashi

Regards,
Rashi

View solution in original post

0 Likes
3 Replies
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello Salvatore,

Thank you for bringing the error to our notice.

I have reported this error to respective team and the error would be fixed in the next sdk (FX3SMassStorage example firmware ) release.

As for now, you can swap the two DMA channel reset under CY_U3P_SIB_EVENT_DATA_ERROR or  CY_U3P_SIB_EVENT_ABORT

  if ((evt == CY_U3P_SIB_EVENT_DATA_ERROR) || (evt == CY_U3P_SIB_EVENT_ABORT))

    {

        /* Transfer has failed. Reset the DMA channel. */

        if (glCmdDirection)

        {

            CyU3PDmaChannelReset ((CyU3PDmaChannel *) &glChHandleMscIn);

        }

        else

        {

            CyU3PDmaChannelReset ((CyU3PDmaChannel *) &glChHandleMscOut);

        }

EDITED:

The same changes need to be done for RAID1 application note example (AN89661):

if (evt == CY_U3P_SIB_EVENT_XFER_CPLT)

.

.

if (glCmdDirection)

     {

CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_CONS_0 | CY_FX_MSC_EP_BULK_IN_SOCKET),

&sockConf);

glMscResidue -= sockConf.xferCount;

     CyU3PDmaMultiChannelReset ((CyU3PDmaMultiChannel *) &glChHandleUSBIn);

}

     else

     {

   CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_PROD_0 + CY_FX_MSC_EP_BULK_OUT_SOCKET),

&sockConf);

   glMscResidue -= sockConf.xferCount;

    if (glRaidMultiChannelValid)

     CyU3PDmaMultiChannelReset ((CyU3PDmaMultiChannel *) &glChHandleUSBOut);

     else

     CyU3PDmaChannelReset (&glChHandleWrErrIn);

     }

Regards,

Rashi

Regards,
Rashi
0 Likes

Hi Rashi,

maybe i'm not getting this right, but to correct the RAID1 example, I think it should be done that way:

  if (glCmdDirection)

  {

    CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_CONS_0 | CY_FX_MSC_EP_BULK_IN_SOCKET), &sockConf);

    glMscResidue -= sockConf.xferCount;

    CyU3PDmaMultiChannelReset (&glChHandleUSBIn);

  }

  else

  {

    CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_PROD_0 + CY_FX_MSC_EP_BULK_OUT_SOCKET), &sockConf);

    glMscResidue -= sockConf.xferCount;

    if (glRaidMultiChannelValid)

      CyU3PDmaMultiChannelReset ((CyU3PDmaMultiChannel *) &glChHandleUSBOut);

    else

      CyU3PDmaChannelReset (&glChHandleWrErrIn);

  }

Is this right?

Anyway, thanks for your fast response!

Salvatore

0 Likes

Hello Salvatore,

Yes, you are right.

The changes need to be done for RAID1 application note example (AN89661):

if (evt == CY_U3P_SIB_EVENT_XFER_CPLT)

.

.

if (glCmdDirection)

     {

CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_CONS_0 | CY_FX_MSC_EP_BULK_IN_SOCKET),

&sockConf);

glMscResidue -= sockConf.xferCount;

     CyU3PDmaMultiChannelReset ((CyU3PDmaMultiChannel *) &glChHandleUSBIn);

}

     else

     {

   CyU3PDmaSocketGetConfig ((uint16_t)(CY_U3P_UIB_SOCKET_PROD_0 + CY_FX_MSC_EP_BULK_OUT_SOCKET),

&sockConf);

   glMscResidue -= sockConf.xferCount;

    if (glRaidMultiChannelValid)

     CyU3PDmaMultiChannelReset ((CyU3PDmaMultiChannel *) &glChHandleUSBOut);

     else

     CyU3PDmaChannelReset (&glChHandleWrErrIn);

     }

Regards,

Rashi

Regards,
Rashi
0 Likes