4 Replies Latest reply on Nov 24, 2017 1:33 AM by tlbrkt_2409941

    Trying to use the FX3 to capture images from OnSemi image sensor

    tlbrkt_2409941

      Trying to use the FX3 to capture images from OnSemi image sensor and have few questions - could not find answer in the docs or forums.   I use the image sensor in trigger mode, so need to read only 1 image upon request.  The image size is known. For example: the buffer size of monochromatic image of 768X768 pixels is 768X768X2 = 1179648 bytes (16 bits per pixel)   I use a GPIF to USB bulk manual channel to capture the image.   Knowing this size:  What should be the buffer size associated with the channel? (i now use size of 16*1024)  What should be the number of buffers allocated to the channel (I use 4)  What should be the packet size (I use 1024)   When capturing images of 512X512 it works well.  But when capturing images of 768X768 and bigger, the received buffer is made of 15-20 last lines of the previous image, and the rest are lines of the currently captured image.  There is some sync problems between the captured and received buffers.Can anyone help with this?

        • 1. Re: Trying to use the FX3 to capture images from OnSemi image sensor
          hppc

          Can you share the firmware source code. Are you using AN75779 example firmware?

          • 2. Re: Trying to use the FX3 to capture images from OnSemi image sensor
            tlbrkt_2409941

            Did not use the AN75779 because I use a triggered image (only one image at a time that is generated upon request)

            I edited the simple GpifToUSB example.

             

            ==================This is the very simple DmaCallback:============================

             

            void

            GpifToUsbDmaCallback (

                    CyU3PDmaChannel   *chHandle,

                    CyU3PDmaCbType_t   type,

                    CyU3PDmaCBInput_t *input)

            {

            // uint8_t high,low;

            uint8_t i=0;

            #ifdef STREAMING_MANUAL

                if (type == CY_U3P_DMA_CB_PROD_EVENT)

                {

                     /*Change few pixels to black */

                     for(i=0; i<50; i++)

                     {

                        input->buffer_p.buffer[7680+i] = 0;

                      }

                    CyU3PDmaChannelCommitBuffer (chHandle, input->buffer_p.count, 0);

                }

                if (type == CY_U3P_DMA_CB_CONS_EVENT)

                {

                    /* Data transfer has been started. Enable the LPM disable loop. */

                    gDoLpmDisable = CyTrue;

                }

            #endif

            }

             

            ==================== This is the header with the relevant definitions. ======================

             

            #include "cyu3types.h"

            #include "cyu3usbconst.h"

            #include "cyu3externcstart.h"

             

             

            #define CY_FX_GPIFTOUSB_DMA_TX_SIZE        (0)                       /* DMA transfer size is set to infinite */

            #define CY_FX_GPIFTOUSB_THREAD_STACK       (0x1000)                  /* Bulk loop application thread stack size */

            #define CY_FX_GPIFTOUSB_THREAD_PRIORITY    (8)                       /* Bulk loop application thread priority */

            #define CY_FX_GPIFTOUSB_PATTERN            (0xAA)                    /* 8-bit pattern to be loaded to the source buffers. */

             

             

            /* Endpoint and socket definitions for the bulk source sink application */

             

             

            #define CY_FX_EP_CONSUMER               0x83    /* EP 3 IN */

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

            #define CY_FX_GPIF_PRODUCER_SOCKET      CY_U3P_PIB_SOCKET_0

             

             

            /* Burst mode definitions: Only for super speed operation. The maximum burst mode

            * supported is limited by the USB hosts available. The maximum value for this is 16

            * and the minimum (no-burst) is 1. */

             

             

            /* Burst length in 1 KB packets. Only applicable to USB 3.0. */

            #ifndef CY_FX_EP_BURST_LENGTH

            #define CY_FX_EP_BURST_LENGTH           (16)

            #endif

             

             

            /* Size of DMA buffers used by the application. Tried many values*/

            /*****

            #ifndef CY_FX_DMA_BUF_SIZE

            #define CY_FX_DMA_BUF_SIZE            (28800) // (26912) (16384) //(32768) (16384)

            #endif

            *******/

             

             

            /* Number of DMA buffers to be used on the channel. */

            #ifndef CY_FX_DMA_BUF_COUNT

            #define CY_FX_DMA_BUF_COUNT             (4)

            #endif

             

             

            /* Parameters for loop-back function. */

            #define CY_FX_EP_LOOP_OUT               (0x02)

            #define CY_FX_EP_LOOP_IN                (0x82)

            #define CY_FX_LOOP_PRODUCER_SOCK        CY_U3P_UIB_SOCKET_PROD_2

            #define CY_FX_LOOP_CONSUMER_SOCK        CY_U3P_UIB_SOCKET_CONS_2

             

             

            #ifndef  STREAMING_MANUAL

            #define  STREAMING_MANUAL (1)

            #endif

             

            ............

            • 3. Re: Trying to use the FX3 to capture images from OnSemi image sensor
              hppc

              To ensure that the GPIF and DMA buffers are in sync, the DMA reset mechanism can be used after each transfer. Please check the AN75779 example for DMA reset procedure. Also as no control signals are used, there is no need for any actual device connectivity on the GPIF II interface when using gpiftousb example. How are you make sure that the data sampling is proper? How is the GPIF-II project modified? Please check the Slave FIFO GPIF interface attached with the app note AN65974 - Designing with the EZ-USB® FX3™ Slave FIFO Interface.

              • 4. Re: Trying to use the FX3 to capture images from OnSemi image sensor
                tlbrkt_2409941

                Like in the AN75779, the  the GPIF reads the image data only when Frame and Line signals are on. The image contains a total of about 1M bytes. It starts only after specific request, and only 1 image is sent from the sensor. The first image is correct, but some how, the first few bytes of the  next image that is initiated and read only few seconds after, contains some data of the prev image. What do you mean by "reset procedure"?