3 Replies Latest reply on Mar 22, 2020 8:53 PM by JayakrishnaT_76

    CX3 buffer issue, how to solve?

    NiEn_2817821

      We are using the CX3 with an IMX219 image sensor.

       

      Facing that the connected PC may not consume data fast enough, we try to discard produced buffers using the CyU3PDmaMultiChannelDiscardBuffer() call, when the number of CY_U3P_DMA_CB_CONS_EVENT is lagging too much behind the number of CY_U3P_DMA_CB_PROD_EVENT.

      This works most of the time, but sometimes CyU3PDmaMultiChannelDiscardBuffer() returns error 0x47 (CY_U3P_ERROR_INVALID_SEQUENCE) – why?

       

      After getting this error 0x47, the gpif state machine most of the time can be reset by calling CyU3PGpifDisable(CyFalse) and CyU3PDmaMultiChannelReset(&DmaStreamingHandle); however, sometimes this makes the gpif state machine and/or the CX3 get completely stucked, and it needs to be hardware reset to be able to communicate on the USB again. Why?

       

      Can you please advise some work-a-rounds?

        • 1. Re: CX3 buffer issue, how to solve?
          JayakrishnaT_76

          Hello,

           

          The API CyU3PDmaMultiChannelDiscardBuffer() returns error 0x47 when the UVC host application does not issue IN tokens fast enough to clear the DMA buffers. There is a workaround mentioned in the following KBA:

          Invalid Sequence Error in Multi-Channel Commit Buffer - KBA218830

           

          Please try this and let me know the result.

           

          Best Regards,

          Jayakrishna

          1 of 1 people found this helpful
          • 2. Re: CX3 buffer issue, how to solve?
            NiEn_2817821

            I got this problem solved by rewriting the code to

             

            Question 1

             

            static int32_t DmaUsbCommitCount = 0;

             

            void DmaCallback(

               CyU3PDmaMultiChannel* chHandle,

               CyU3PDmaCbType_t  type,

               CyU3PDmaCBInput_t* input

            )

            {

               CyU3PDmaBuffer_t dmaBuffer;

               CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

             

               if (CY_U3P_DMA_CB_PROD_EVENT & type)

               {

                  status = CyU3PDmaMultiChannelGetBuffer(chHandle, &dmaBuffer, CYU3P_NO_WAIT);

                  // add header

                  if (3 < DmaUsbCommitCount) {

            /* Discard Buffer */

            status = CyU3PDmaMultiChannelDiscardBuffer(chHandle);

            if (status != CY_U3P_SUCCESS) {

            // error handling

            }

                  }

                  else {

            /* Commit Buffer to USB*/

            status = CyU3PDmaMultiChannelCommitBuffer(chHandle, (dmaBuffer.count + SD_PROD_HEADER), 0);

            if (status != CY_U3P_SUCCESS) {

            // error handling

            }

            else

            {

            DmaUsbCommitCount++;

            }

                  }

               }

               if (CY_U3P_DMA_CB_CONS_EVENT & type)

               {

            DmaUsbCommitCount--;

               }

            }

            • 3. Re: CX3 buffer issue, how to solve?
              JayakrishnaT_76

              Hello,

               

              Please let me know how did you resolve this issue. Is it by using my suggestion in the response1 or is it by using your modification of the code in your response 2? Please let me know if you have anymore queries on this.

               

              Best Regards,

              Jayakrishna