9 Replies Latest reply on Aug 19, 2019 5:19 AM by KySa_4218291

    FX3 Performance Questions

    KySa_4218291

      Hello,

      after reading the manuals I still have some questions...

      1) A Socket is connection between device and memory... right? So for streaming I need at least 2 sockets. One from FX3(GPIF) to memory and one from memory to i.e. USB ... this is what called producer and consumer socket... is that right so far?
      2)When do the consumer stream data from memory to usb? when the buffer is full? So if i alocated 1024bytes for dma_buffer the socket will send data after 1024bytes are full?
      3)After a socket red or wrote data it takes some time for it to get the dma again? So if I want to stream as quick as possible I have to have multiple producer, because the consumer can reset it self while the producer is writing new data.
      In thet case if every point is right...
      for maximal performance in streaming i would need 4 threads with 4 producer sockets and 1 consumer... and from now on i don't have an idea how should they work?
      I mean do i link 4 sockets to differen buffer and all of the buffers to one consumer?

       

      PS: and how do I init 2 threads? So I can use in GPIF II TH0 and TH1?

        • 1. Re: FX3 Performance Questions
          RashiV_61

          Hello,

           

          1) Yes, the socket is a connection between peripheral hardware block and FX3 RAM. Socket points to DMA descriptor. DMA  descriptors have the information about the DMA buffer. Yes, for data transfer through DMA, a DMA channel is to be created. DMA channel needs two sockets : Producer sockets and Consumer socket.

           

          2) The sockets can directly signal each other. For example, for GPIF to USB DMA transfer if the buffer size is 1024 bytes. The GPIF socket will signal the USB socket that it has filled the data in the buffer (buffer full). Similarly, the USB socket can signal GPIF socket when it has consumed the data ( buffer empty).This is done in Automatic DMA channel. Alternatively, the GPIF socket can send an interrupt to the FX3 CPU to notify it that the GPIF socket filled a DMA buffer. The FX3 CPU can relay this information to the USB socket. This is done in Manual DMA channel implementation.

           

          3) When continuous data transfer is done(eg. video streaming),  to avoid the data loss in buffer switching, thread switching is done. Thread switching is faster than buffer switching (switching from one DMA descriptor to another). This is the reason for using more than one producer sockets.

           

          - This is a snippet for DMA channel configuration for Manual DMA Channel

           

              dmaMultiConfig.size           = CY_FX_UVC_STREAM_BUF_SIZE;

              dmaMultiConfig.count          = CY_FX_UVC_STREAM_BUF_COUNT;

              dmaMultiConfig.validSckCount  = 2;

              dmaMultiConfig.prodSckId [0]  = (CyU3PDmaSocketId_t)CY_U3P_PIB_SOCKET_0;

              dmaMultiConfig.prodSckId [1]  = (CyU3PDmaSocketId_t)CY_U3P_PIB_SOCKET_1;

              dmaMultiConfig.consSckId [0]  = (CyU3PDmaSocketId_t)(CY_U3P_UIB_SOCKET_CONS_0 | CY_FX_EP_VIDEO_CONS_SOCKET);

              dmaMultiConfig.prodAvailCount = 0;

              dmaMultiConfig.dmaMode        = CY_U3P_DMA_MODE_BYTE;

              dmaMultiConfig.notification   = CY_U3P_DMA_CB_PROD_EVENT | CY_U3P_DMA_CB_CONS_EVENT;

              dmaMultiConfig.cb             = CyFxUvcApplnDmaCallback;

           

           

           

          - The threads that we are talking about on the GPIF II side of FX3 are not same as the threads that you create in software.They are not software threads. But they are hardware threads specific to FX3. The threads switching can be switched using  address lines [A1:A0].  If the address lines are not used, there is option in GPIF designer tool to choose a particular thread.(Refer the attachment)

           

          You can refer to this app note  https://www.cypress.com/file/123506/download (section 3.3 & 3.4) for better understanding. It uses two threads for streaming data. You can also refer to fx3_uvc.cyfx file for the state machine designing https://www.cypress.com/documentation/application-notes/an75779-how-implement-image-sensor-interface-using-ez-usb-fx3-us… 

           

          Regards,

          Rashi

          • 2. Re: FX3 Performance Questions
            KySa_4218291

            Thank you! I am atm trying to use the content from bulkmanytoone example... i think it should also work?

            You remeber my given statemachine from before? so i need 4 sockets for switching threads, right? I try to reverse enginner that somebody did at our project and gone...

            • 3. Re: FX3 Performance Questions
              RashiV_61

              Yes. You can use that firmware example for many to one  DMA channel (Auto Mode). Modifications will be required according to your application.

               

              Regards,

              Rashi

              • 4. Re: FX3 Performance Questions
                KySa_4218291

                well i am trying to combine autobulk and manytoone....  so i have to use multychanel dma not the normal in autobulkloop, add sockets, and well just do the same as in manytoone?

                • 5. Re: FX3 Performance Questions
                  RashiV_61

                  Yes. You can do it by changing the DMA channel configuration (adding appropriate sockets) code in the autobulklp example.

                   

                  Regards,

                  Rashi

                  1 of 1 people found this helpful
                  • 6. Re: FX3 Performance Questions
                    KySa_4218291

                    Thank you very much for the support. Last question before i go again try and error... I actually don't need the EP sockets, I only need the GPIF sockets.. is that true?

                    • 7. Re: FX3 Performance Questions
                      RashiV_61

                      By EP sockets, do you mean the USB sockets??

                      The producer and consumer sockets can be decided by the direction of data flow in you application. The socket writing to the buffer will be producer and socket reading from the buffer will be consumer socket.

                       

                      Regards,

                      Rashi

                      1 of 1 people found this helpful
                      • 8. Re: FX3 Performance Questions
                        KySa_4218291

                        I mean i will have to do something like:

                        #define CY_FX_EP_CONSUMER               0x81    /* EP 1 IN */

                        #define CY_FX_EP_CONSUMER_SOCKET        CY_U3P_UIB_SOCKET_CONS_1    /* Socket 1 is consumer */

                        #define CY_FX_GPIF_PRODUCER_SOCKET_0      CY_U3P_PIB_SOCKET_0

                        #define CY_FX_GPIF_PRODUCER_SOCKET_1     CY_U3P_PIB_SOCKET_1
                        ....

                         

                        and not

                         

                        #define CY_FX_EP_CONSUMER                   0x81    /* EP 1 IN */

                        #define CY_FX_EP_PRODUCER_0               0x01    /* EP 1 IN */

                        #define CY_FX_EP_PRODUCER_1               0x02    /* EP 2 IN */

                        • 9. Re: FX3 Performance Questions
                          KySa_4218291

                          Oh it works... not with auto_master example but with my statemachine and modified gpiftousb example... I don't know why the first one doesnt want. But it works Thank you very much for your help!