2 Replies Latest reply on Jan 25, 2016 11:18 AM by ryan.weiss

    Isochronous USB Transfer Completion Detection

    ryan.weiss

      PSoC Forums,

         

      I am using Isochronous USB to transfer data from the PsoC5LP Devkit to a host PC.  If, I sit in a tight loop loading the endpoint with data,  the host receives everything intact. In my application, I will not be able to sit in a tight loop feeding the end point as I must wait for data to be created before I can send it. It takes 10s of ms to generate enough data to transmit.

         

      If I load the endpoint with data, delay a few ms, then load the endpoint with new data and delay a few ms, then the data received by the host is corrupted,  I believe that the issue is caused by new data being loaded into the endpoint while data is being sent over the USB bus. I need a way of knowing when my Isochronous USB transfer has finished that way I can set the endpoint's paylaod length to 0 while I am waiting for new data to be created. Also, I need a way of knowing when it is safe to load the endpoint with new data, as it seems to me that there could be an issue caused when loading new data into the endpoint. I am imagining issues popping up with the USB endpoint being halfway loaded with new data and a USB data request coming in from the host.

         

      Any help and feedback is greatly appreciated! 

         

      Ryan

        • 1. Re: Isochronous USB Transfer Completion Detection
          hima

          Hello,

             

          I just want to check if you are checking the if the IN EP is empty before loading new data.

             

          if (USBFS_GetEPState(1) == USBFS_IN_BUFFER_EMPTY)
                          {            
                              /*Rearm the IN Endpoint (EP1) */
                              USBFS_LoadInEP(EP1, USBFS_NULL, sizeof(EP1_RAM));               
                             }

             

          The above code snippet loads data only if the IN EP is empty.

             

          Thanks,

             

          Hima

          • 2. Re: Isochronous USB Transfer Completion Detection
            ryan.weiss

            Thank you Hima,

               

            USBFS_GetEPState and USBFS_IN_BUFFER are the function and register I need to check for my specific host application.  I am using the USBFS_GetEPState function to  check if the endpoint is empty before loading in data, and again to check to see if it is full before making the endpoint have no data. This ensures the host program reads the new data once and receives nothing until new data is ready.   Below is the section of code completing this task.  

               

            if(USBFS_1_IN_BUFFER_EMPTY == USBFS_1_GetEPState(IN_EP))
                        {
                            USBFS_1_LoadInEP(IN_EP, counter_ptr, USB_BUFFER_TX_SIZE); 
                            while(USBFS_1_IN_BUFFER_FULL == USBFS_1_GetEPState(IN_EP)){}
                            USBFS_1_LoadInEP(IN_EP, counter_ptr, 0);
                         }

               

            Thanks,

               

            Ryan