3 Replies Latest reply on Sep 12, 2019 6:23 PM by HirotakaT_91

    CyU3PDmaMultiChannelSetXfer ERROR

    user_2585021

      I'm using @an75779 UVC sample code.

       

      At first, UVC is captured from the application and then the capture is forcibly stopped.

      Next, I start the capture again, the following error may occur:

       

      "CyU3PDmaMultiChannelSetXfer = 0x43"

      At the reception timing of CY_FX_UVC_STREAM_EVENT timing.

       

      If an error occurs, the firmware must be reset (powered off).

       

       

      1. What is the cause of this phenomenon?

       

      2. What are the factors when the return value of CyU3PDmaMultiChannelSetXfer is 0x43?

       

      best regards.

        • 1. Re: CyU3PDmaMultiChannelSetXfer ERROR
          HirotakaT_91

          Hello,

           

          A1. A2.

          Error code 0x43 stands for CY_U3P_ERROR_ALREADY_STARTED which means that "An object/module that is already active is being started."

          CyU3PDmaMultiChannelSetXfer() API is used for preparing Multi-channel DMA for data transfer. If specified channel has already prepared, it may be shown.

           

          I have a question to solve its query.

          Q. I have a concern about your modification. What kind of modification have you done on AN75779? AN75779 example firmware does not call CyU3PDmaMultiChannelSetXfer() when CY_FX_UVC_STREAM_EVENT event is set.

           

          If I misunderstood what you are saying, please clarify more.

           

          Thanks & Best regards,

          Hirotaka Takayama

          • 2. Re: CyU3PDmaMultiChannelSetXfer ERROR
            user_2585021

            Dear Hirotaka Takayama

             

            Thank for your comment.

             

            Below is our "UVCAppThread_Entry" source code.

            Adding LED control to indicate capture or stop via GPIO.(Modify original UVC sample code.)

             

            I have some question.

             

            Q1. If the capture start instruction is executed from the UVC application in the capture stop state

            (= DMA transfer stop state), will CY_FX_UVC_STREAM_EVENT occur?

             

            Q2. CY_FX_UVC_STREAM_ABORT_EVENT if capture stop is instructed by the UVC application regardless        of whether the capture is in progress Will occur?

            Q3. The previous question interprets that if you start capture during capture, there will be a problem.
                   The operation from the UVC application is First capture start-> Stop capture-> Second capture start is in         progress. At this time, the second and subsequent capture starts will result in an error.

             

                   In order to solve this problem, will the "CyU3PDmaMultiChannelReset function" be called when the stop           instruction for the first capture is executed?

             

                  *I suspect the problem of the internal variable “clearFeatureRqtReceived” we added.

             

            Best Regards

            ---Our source code---

            void UVCAppThread_Entry (  uint32_t input )

            {

                CyU3PReturnStatus_t apiRetStatus;

                uint32_t            flag;

             

                /* Initialize the Uart Debug Module */

                CyFxUVCApplnDebugInit ();

             

                /* Initialize the I2C interface */

                CyFxUVCApplnI2CInit ();

             

                // Initialize the GPIO

                GpioInit();

             

                /* Initialize the UVC Application */

                CyFxUVCApplnInit ();

             

                /*

                   The actual data forwarding from sensor to USB host is done from the DMA and GPIF callback

                   functions. The thread is only responsible for checking for streaming start/stop conditions.

                 

                   The CY_FX_UVC_STREAM_EVENT event flag will indicate that the UVC video stream should be started.

             

             

                   The CY_FX_UVC_STREAM_ABORT_EVENT event indicates that we need to abort the video streaming. This

                   only happens when we receive a CLEAR_FEATURE request indicating that streaming is to be stopped,

                   or when we have a critical error in the data path.

                 */

                for (;;)

                {

                    apiRetStatus = CyU3PEventGet (&glFxUVCEvent, CY_FX_UVC_STREAM_ABORT_EVENT | CY_FX_UVC_STREAM_EVENT,

                            CYU3P_EVENT_OR_CLEAR, &flag, LOOP_TIMEOUT);

             

             

                    if (apiRetStatus == CY_U3P_SUCCESS)

                    {

                        /* Request to start video stream. */

                        if ((flag & CY_FX_UVC_STREAM_EVENT) != 0)

                        {

             

                            /* Start with frame ID 0. */

                            glUVCHeader[1] &= ~CY_FX_UVC_HEADER_FRAME_ID;

             

             

                            /* Make sure we return to an active USB link state and stay there. */

                            CyU3PUsbLPMDisable ();

                            if (CyU3PUsbGetSpeed () == CY_U3P_SUPER_SPEED)

                            {

                                CyU3PUsbSetLinkPowerState (CyU3PUsbLPM_U0);

                                CyU3PBusyWait (200);

                            }

             

                            /* Set DMA Channel transfer size, first producer socket */

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

                            if (apiRetStatus != CY_U3P_SUCCESS)

                            {

                                /* Error handling */

                                CyU3PDebugPrint (4, "DMA Channel Set Transfer Failed, Error Code = %d\r\n", apiRetStatus);

                                CyFxAppErrorHandler (apiRetStatus);

                            }

             

             

                            /* Start the state machine from the designated start state. */

                            apiRetStatus = CyU3PGpifSMStart (START_SCK0, ALPHA_START_SCK0);

                            if (apiRetStatus != CY_U3P_SUCCESS)

                            {

                                /* Error Handling */

                                CyU3PDebugPrint (4, "Starting GPIF state machine failed, Error Code = %d\r\n", apiRetStatus);

                                CyFxAppErrorHandler (apiRetStatus);

                            }

             

                            // Update LED

                            GpioSetLed(LED_CAPT_STATUS, 1); // LED(Capture Status) ON(Capture in progress)

                            GpioSetLed(LED_BUFFER_OVER, 0); // LED(Buffer Overflow) OFF(No abnormality)

                        }

             

                        /* Video stream abort requested. */

                        if ((flag & CY_FX_UVC_STREAM_ABORT_EVENT) != 0)

                        {

             

                            if (!clearFeatureRqtReceived)

                            {

                                apiRetStatus = CyU3PDmaMultiChannelReset (&glChHandleUVCStream);

                                if (apiRetStatus != CY_U3P_SUCCESS)

                                {

                                    CyFxAppErrorHandler (apiRetStatus);

                                }

             

                                /* Flush the Endpoint memory */

                                CyU3PUsbFlushEp (CY_FX_EP_BULK_VIDEO);

                            }

             

                            clearFeatureRqtReceived = CyFalse;

             

                            /* Allow USB low power link transitions at this stage. */

                            CyU3PUsbLPMEnable ();

             

                            // Update LED

                            GpioSetLed(LED_CAPT_STATUS, 0); // LED(Capture Status) OFF(Capture stopped)

                        }

                    }

                }

            }

            --- My source code ---

            • 3. Re: CyU3PDmaMultiChannelSetXfer ERROR
              HirotakaT_91

              Hello,

               

              A1. Yes. After the default streaming mode is decided, the UVC driver issues a COMMIT request.

              Please refer to "2.3.2 UVC-Specific Requests" in AN75779 for more information.

               

              A2. Yes. The camera may be disconnected from the Host, the USB Host program may close, or the USB Host may issue a reset or suspend request to FX3.

              These actions trigger the CY_FX_UVC_STREAM_ABORT_EVENT event.

              It is described in "5.8 Terminating the Video Streaming" in AN75779.

               

              A3. I guess there are issues on your added code.

              When UVC application stops, CY_FX_UVC_STREAM_ABORT_EVENT is called as per my above answer.

              Then, CyFxUvcApplnStop() function is called and in this function, some of the APIs are described for stopping its Application. Obviously, CyU3PDmaMultiChannelReset() is included in this function.

               

              I checked your main Thread code.

              Kindly do place the EP in NAK mode before invoking cleaning up APIs (CyU3PUsbFlushEp, CyU3PDmaMultiChannelReset, etc.)

              Kindly do not use CyU3PGpifSMStart() if the GPIF state is not in the idle state.

              Hopefully, you will more refer to our AN75779 and consider to use our example code further.

               

              For your reference, I will attach my document which described basic flow on AN75779 in Japanese.

               

              Best regards,

              Hirotaka Takayama