7 Replies Latest reply on Dec 20, 2019 1:30 AM by YashwantK_46

    Problems with EP0 FX3 USB 2.0

    MaFa_974161

      Hello.

       

      I'm using FX3, USB 2.0 cable on USB 2.0 port, and I write a firmware that send 64 byte on EP0 using

       

       

       

       

      CyU3PUsbSendEP0Data(64, buffer).

       

      I notice that if I use "USB Control Center" and set "Bytes to Transfer" major than 64 I obtain TIMEOUT and no data ...

       

      "CONTROL IN transfer failed with Error Code:997"

        • 1. Re: Problems with EP0 FX3 USB 2.0
          YashwantK_46

          Hello,


          Can you please tell which frimware you are using to program FX3?

          If it is not a SDK example frimware, please share the firmware as well.

           

          Also, are the 64 Bytes sent, randomly generated data?

           

          Error code:997 arises when the buffer are either Empty when you try to read them or Full when you try to write to them.


          Regards,

          Yashwant

          • 2. Re: Problems with EP0 FX3 USB 2.0
            MaFa_974161

            I develop my firmware using

            GpifToUsb from

            EZ-USB FX3 SDK 1.3

            and modify CyFxApplnUSBSetupCB

            in this way

             

             

             

            uint8_t glEp0Buffer[4096] __attribute__ ((aligned (32)));

             

            /* Callback to handle the USB setup requests. */
            CyBool_t
            CyFxApplnUSBSetupCB (
                    uint32_t setupdat0, /* SETUP Data 0 */
                    uint32_t setupdat1  /* SETUP Data 1 */
                )
            {
                /* Fast enumeration is used. Only requests addressed to the interface, class,
                 * vendor and unknown control requests are received by this function.
                 * This application does not support any class or vendor requests. */

                uint8_t  bRequest, bReqType;
                uint8_t  bType, bTarget;
                uint16_t wValue, wIndex, wLength;
                CyBool_t isHandled = CyFalse;

              

                 /* Decode the fields from the setup request. */
                bReqType = (setupdat0 & CY_U3P_USB_REQUEST_TYPE_MASK);
                bType    = (bReqType & CY_U3P_USB_TYPE_MASK);
                bTarget  = (bReqType & CY_U3P_USB_TARGET_MASK);
                bRequest = ((setupdat0 & CY_U3P_USB_REQUEST_MASK) >> CY_U3P_USB_REQUEST_POS);
                wValue   = ((setupdat0 & CY_U3P_USB_VALUE_MASK)   >> CY_U3P_USB_VALUE_POS);
                wIndex   = ((setupdat1 & CY_U3P_USB_INDEX_MASK)   >> CY_U3P_USB_INDEX_POS);
                wLength  = ((setupdat1 & CY_U3P_USB_LENGTH_MASK)  >> CY_U3P_USB_LENGTH_POS);

              

               if(bType == CY_U3P_USB_VENDOR_RQT)
               {

                  if(bRequest == 0x01)

             

                  {

                     uint8_t myBuf[64] = { /* some data */ };

                     CyU3PUsbSend(64, myBuf);

                  }

               }

            }

            • 3. Re: Problems with EP0 FX3 USB 2.0
              YashwantK_46

              Hi,

               

              There is no API which corresponds to CyU3PUsbSend() in FX3 SDK source code and so, there's no data transfer in such a case.


              You will have to use CyU3PUsbSendEP0Data() in place of the above API inorder to send data over EP0 to the host.

               

              Please do try the above mentioned API and get back with the results.


              Regards,

              Yashwant

              • 4. Re: Problems with EP0 FX3 USB 2.0
                MaFa_974161

                I'm using CyU3PUsbSendEP0Data api

                but I write CyU3PUsbSendData instead of CyU3PUsbSendEP0Data in forum message.

                 

                I have problem

                • 5. Re: Problems with EP0 FX3 USB 2.0
                  YashwantK_46

                  Hello,

                   

                  Please refer to the attached screenshot.

                  I have tried to reproduce the same changes as you told and got the following results as attached in the screenshot.


                  Please ensure that the Direction : IN and Req Type : Vendor and Target ; Device and Req Code : 0x01.

                   

                  I didn't get the 997 error when using IN and got it while using OUT, so my guess is you might be using the direction wrongly as this data comes from FX3 into PC and so the Direction should be IN.

                   

                  Also, you could try to declare your buffer as what i have mentioned with a RED box in the screenshot.

                   

                  Regards,

                  Yashwant

                  • 6. Re: Problems with EP0 FX3 USB 2.0
                    MaFa_974161

                    I don't understand why on my PC this still not work.

                    I'm using EZ-USB FX3 SDK 1.3 ... you are you using newer version ?

                    • 7. Re: Problems with EP0 FX3 USB 2.0
                      YashwantK_46

                      Hi,


                      Yes, i am using FX3 SDK 1.3.4

                      And everything is working as expected.

                      Can you please check once and update the results on SDK 1.3.4?


                      Regards,

                      Yashwant