2 Replies Latest reply on Dec 1, 2019 11:10 PM by AnMa_1312801

    PSoC 5 USBFS problem with lost frames

    AnMa_1312801

      Hello,

       

      I'm having some problems getting my Generic 8-Byte HID interface working properly, and i don't know where is reason of this. I made my configuration as simple as I can with AN82072 to find reason of problem but have no luck.

       

      Schematic is

      and main function:

      int main(void)
      {
          CyGlobalIntEnable; /* Enable global interrupts. */
          PWM_Start();
          USBFS_Start(0, USBFS_5V_OPERATION);
          while(USBFS_bGetConfiguration()==0){}
          for(;;)
          {        
              if(USBFS_GetEPState(IN_ENDPOINT) == USBFS_IN_BUFFER_EMPTY) // IN_ENDPOINT defined as 0x01
              {
                  IN_Data_Buffer[0]=0x73; //115 as test, for debugging
                  IN_Data_Buffer[1]=Pin_2_Read();// read button pin
                  USBFS_LoadInEP(IN_ENDPOINT, IN_Data_Buffer, MAX_NUM_BYTES);// MAX_NUM_BYTES defined as 8
                  USBFS_EnableOutEP(OUT_ENDPOINT);// IN_ENDPOINT defined as 0x02
              }
              if(USBFS_GetEPState(OUT_ENDPOINT) == USBFS_OUT_BUFFER_FULL)
              {
                  OUT_COUNT = USBFS_GetEPCount(OUT_ENDPOINT);
                  USBFS_ReadOutEP(OUT_ENDPOINT, OUT_Data_Buffer, OUT_COUNT);
                  PWM_Duty_Cycle = OUT_Data_Buffer[PWM_cmp_Pos];
                  PWM_WriteCompare(PWM_Duty_Cycle);
                  USBFS_EnableOutEP(OUT_ENDPOINT);
              }
              USBFS_EnableOutEP(OUT_ENDPOINT);
          }
      }
      

       

      HID report was configured same as in AN82072.

       

      And here is troubles.

      I take my python and rust and tried to write some code to communicate with MCU with simple code like that:

      Similar code i used on rust with hid.dll in windows 10

      This is very  strange but when i try to lit led up (second byte in array is PWM DC) and send buffer to psoc - nothing happens in 3 or 5 attempts (but True returns) and then after numerous attempts of buffer sending - it looks like data sent and PWM changes its DC.

      Sometimes it works at 3 attempt, sometime - at 15 O_o.

       

      So, the main question is how i should configure USBFS to communicate between PC and MCU so that MCU gets the data without excessive attempts or I get an error if no data ws sent or read out by MCU?

        • 1. Re: PSoC 5 USBFS problem with lost frames
          EktaN_26

          Hello Anton,

           

          I have attached a sample project (Generic 8 byte HID) based on the appnote: AN82072. You can make similar configurations for the USBFS component as in the attached project. Can you please use this project for testing and let me know if you are facing the same issue. In case the problem persists please attach your project so that we can have better insight of the issue.

           

          I have tested this project with the GUI that comes with the Appnote and the project was working fine.

          Can you also test you project on the same GUI and let me know if you are able to observe changes in the intensity of LED?

           

          Best Regards

          Ekta

          • 2. Re: PSoC 5 USBFS problem with lost frames
            AnMa_1312801

            After many days of experiments it looks like USBFS is working not very good with Windows systems. The code in appnote project is works in common cases but there is some issues i had to make my own code based on appnote. Anyway -  thanks for help, i'll mark your answer as correct decision to close that thread.