Invalid Sequence Error in Multi-Channel Commit Buffer - KBA218830

Version 1
    Version: **

     

    Question:

    “Error in CyU3PDmaMultiChannelCommitBuffer: code 71” message is displayed on a UART terminal when streaming video through FX3. What is the reason for this error and how do you recover from this error?

     

    Answer:

    “Error in CyU3PDmaMultiChannelCommitBuffer: code 71” message is displayed when there is a DMA buffer overflow. Error Code 71 refers to a ‘CY_U3P_ERROR_INVALID_SEQUENCE’ error. This error may occur if the UVC host application does not issue IN tokens fast enough to clear the DMA buffers.

    To recover from a code 71 error:

    1. Increase the DMA buffer space allocated in the firmware.
    2. Implement the following in the example project associated with AN75779 :   
          
      1. Set a flag (say, commit_buffer_failure) in the CyFxUvcApplnDmaCallback() function,
            when CyU3PDmaMultiChannelCommitBuffer() API fails to return CY_U3P_SUCCESS. 
      2.   
      3.    

        In the for(;;) loop of the UVCAppThread_Entry() function, check if this flag is set. If yes, implement the following code snippet to reset the DMA channel and restart GPIF II state machine.

            

        if (commit_buffer_failure == 1)

            

                    {

            

                                commit_buffer_failure = 0;

            

                                /* Stop the GPIF state machine to stop data transfers through FX3 */

            

                                CyU3PGpifDisable (CyFalse);

            

                                streamingStarted = CyFalse;

            

         

            

                                /* Place the Endpoint in NAK mode before cleaning up the pipe. */

            

                                apiRetStatus = CyU3PUsbSetEpNak (CY_FX_EP_BULK_VIDEO, CyTrue);

            

                                if (apiRetStatus != CY_U3P_SUCCESS)

            

                {

            

                                            CyU3PDebugPrint (4, "\r EP_NAK=%d\n", apiRetStatus);

            

                                }

            

                                /* Reset the DMA channel and flush the endpoint pipe. */

            

                                apiRetStatus = CyU3PDmaMultiChannelReset (&glChHandleUVCStream);

            

                                if (apiRetStatus != CY_U3P_SUCCESS)

            

              {

            

                                    CyU3PDebugPrint (4, "\r DMA_RESET=%d\n", apiRetStatus);

            

                                 }

            

                                apiRetStatus = CyU3PUsbFlushEp (CY_FX_EP_BULK_VIDEO);

            

                                if(apiRetStatus != CY_U3P_SUCCESS)

            

             {

            

                                    CyU3PDebugPrint (4, "\r EP_FLUSH=%d\n", apiRetStatus);

            

                                  }

            

                                apiRetStatus = CyU3PDmaMultiChannelSetXfer (&glChHandleUVCStream, 0, 0);

            

                                if (apiRetStatus != CY_U3P_SUCCESS)

            

                                {

            

                                            CyU3PDebugPrint (4, "\r DMA_XFER  = %d\n", apiRetStatus);

            

                                }

            

                                apiRetStatus = CyU3PUsbSetEpNak (CY_FX_EP_BULK_VIDEO, CyFalse);

            

                                if(apiRetStatus != CY_U3P_SUCCESS)

            

            {

            

                                    CyU3PDebugPrint (4, "\r EP_ACK=%d\n", apiRetStatus);

            

                                  }

            

                   apiRetStatus = CyU3PGpifSMStart (START_SCK0, ALPHA_START_SCK0);

            

                                if (apiRetStatus != CY_U3P_SUCCESS)

            

                              {

            

                                 CyU3PDebugPrint (4, "CyU3PGpifSMStart  = %d\n", apiRetStatus);

            

                                }

            

                                apiRetStatus = CyU3PGpifSMSwitch (257, 0, 257, 0, 2);

            

                                if (apiRetStatus != CY_U3P_SUCCESS)

            

                             {

            

                                 CyU3PDebugPrint (4, "CyU3PGpifSMSwitch  = %d\n", apiRetStatus);

            

                              }

            

                                streamingStarted = CyTrue;

                  }
      4.