5 Replies Latest reply on Sep 11, 2018 2:13 AM by lk960825_3660966

    Use two types of DMA Channel?

    lk960825_3660966

      Hi guys:

       

           I use FX3 to implement UVC protocol and video transmission in SS mode of USB3.0..

           I have used DMAMutilChannal for video data transmission,use register mode for serial data transmission.But now serial data transmission seems to be apart from some problems.So I want to use serial DMA mode for data transfer.

           I would like to ask FX3 to support the use of two different types of DMA channels?In other words, can I use DMAMutilChanel for video transmission and DMA mode for serial data transmission?If there is support, is there a example to refer to?

       

      Best regards,

      Luca L

        • 1. Re: Use two types of DMA Channel?
          abga

          Hi,

           

          Yes you can use both DMAMultiChannel for video data transmission and DMA channel for serial transfer simultaneously.

          Currently we have AN 75779 in which I2C transfer as well as Video transfer is done via DMA channels.

          Here is the link of the AN 75779 for your reference.

          http://www.cypress.com/documentation/application-notes/an75779-how-implement-image-sensor-interface-using-ez-usb-fx3-usb

           

          Thanks & Regards

          Abhinav

          • 2. Re: Use two types of DMA Channel?
            lk960825_3660966

            Hi Abhinav:

                

                 We have opened up a memory space for the storage of control instructions.And we pull out the FX3's RX and TX pins to ARM.I need to use the serial port to send instructions to ARM.We found CyU3PUartTransmitBytes API will have a significant delay in sending data to ARM.So decided to use DMA mode.

                 I have already referred to AN75779, and now I have some puzzles.

             

                 1.When I burn the routine to the development board,Uart dont send or receive any data.

                 2.I made a change on AN75779,but I don't know how to configure DMA channel,especially dmaConfig.prodSckId and dmaConfig.consSckId.

             

            Here is my changed code,it doesnt work,How can I modify?

             

            ( DPINFO is a debug print function, now it doesn't work,we don't need to pay attention )

             

            static void CyFxUVCAppUartDMAModeInit(void)

            {

                CyU3PUartConfig_t uartConfig;

                CyU3PReturnStatus_t apiRetStatus;

                CyU3PDmaChannelConfig_t dmaConfig;

             

             

                /* Initialize the UART for printing debug messages */

                apiRetStatus = CyU3PUartInit ();

                if (apiRetStatus != CY_U3P_SUCCESS)

                {

                DPINFO(3, "%d,UART Init Success..\r\n", __LINE__);

                }

             

             

                /* Set UART Configuration */

                uartConfig.baudRate = CY_U3P_UART_BAUDRATE_9600;

                uartConfig.stopBit  = CY_U3P_UART_ONE_STOP_BIT;

                uartConfig.parity   = CY_U3P_UART_NO_PARITY;

                uartConfig.txEnable = CyTrue;

                uartConfig.rxEnable = CyTrue;

                uartConfig.flowCtrl = CyFalse;

                uartConfig.isDma    = CyTrue;

             

             

                /* Set the UART configuration */

                apiRetStatus = CyU3PUartSetConfig (&uartConfig, NULL);

                if (apiRetStatus != CY_U3P_SUCCESS)

                {

                     DPINFO(3, "%d,SetConfigError\r\n", __LINE__);

                }

             

             

                /* Set the UART transfer */

                apiRetStatus = CyU3PUartTxSetBlockXfer (0xFFFFFFFF);

                if (apiRetStatus != CY_U3P_SUCCESS)

                {

                     DPINFO(3, "%d,TX SetBlockXferError\r\n", __LINE__);

                }

                apiRetStatus = CyU3PUartRxSetBlockXfer (0xFFFFFFFF);

                if (apiRetStatus != CY_U3P_SUCCESS)

                {

                    DPINFO(3, "%d,RX SetBlockXferError\r\n", __LINE__);

                }

                ///

                CyU3PMemSet ((uint8_t *)&dmaConfig, 0, sizeof(dmaConfig));

                dmaConfig.size = 0x400;

                dmaConfig.count = 1;

                dmaConfig.dmaMode = CY_U3P_DMA_MODE_BYTE;

                dmaConfig.prodHeader = 0;

                dmaConfig.prodFooter = 0;

                dmaConfig.consHeader = 0;

                dmaConfig.prodAvailCount = 0;

             

                ///TX config

                dmaConfig.prodSckId = CY_U3P_LPP_SOCKET_UART_PROD; //I dont know how to config

                dmaConfig.consSckId = CY_U3P_LPP_SOCKET_UART_CONS; //I dont know how to config

                dmaConfig.notification = 0;

                dmaConfig.cb = NULL;

                apiRetStatus = CyU3PDmaChannelCreate (&glChHandleTxUart, CY_U3P_DMA_TYPE_MANUAL_OUT, &dmaConfig);

                if (apiRetStatus != CY_U3P_SUCCESS)

                {

                     DPINFO(3, "%d,TX ChannelError\r\n", __LINE__);

                }

                ///RX config

                dmaConfig.prodSckId = CY_U3P_CPU_SOCKET_CONS;//I dont know how to config

                dmaConfig.consSckId = CY_U3P_LPP_SOCKET_UART_PROD;//I dont know how to config

                dmaConfig.notification = 0;

                dmaConfig.cb = NULL;

                apiRetStatus = CyU3PDmaChannelCreate (&glChHandleRxUart, CY_U3P_DMA_TYPE_MANUAL_IN, &dmaConfig);

                if (apiRetStatus != CY_U3P_SUCCESS)

                {

                     DPINFO(3, "%d,RX ChannelError\r\n", __LINE__);

                }

            }

             

            /*send data fucn*/

            CyU3PReturnStatus_t SendUartData(uint8_t *buffer, int Length)

            {

               CyU3PReturnStatus_t apiRetStatus;

               CyU3PDmaBuffer_t dmaUARTBuffer;

               // Get an out buffer.

               apiRetStatus = CyU3PDmaChannelGetBuffer(&glChHandleTxUart, &dmaUARTBuffer, CYU3P_WAIT_FOREVER);

               if (apiRetStatus != CY_U3P_SUCCESS)

               {

                    DPINFO(3, "GetBufferError%d,\r\n", __LINE__);

                    return apiRetStatus;

               }

               CyU3PMemCopy(dmaUARTBuffer.buffer, buffer, Length);

               apiRetStatus = CyU3PDmaChannelCommitBuffer (&glChHandleTxUart, Length, 0);

               if (apiRetStatus != CY_U3P_SUCCESS)

               {

                    DPINFO(3, "%d,CommitBufferError\r\n", __LINE__);

                    return apiRetStatus;

               }

               return apiRetStatus;

            }

             

             

            Thanks & Regards

            Luca L.

            • 3. Re: Use two types of DMA Channel?
              abga

              Hi,

               

              DMA channel is used to transfer the data from one block to other. To configure DMA you need buffers, producer socket( which will generate the data and fill those buffers) and consumer socket (which will consume data and empty those buffers for reuse). Suppose you want to send the data from GPIF to USB then producer socket is of GPIF and consumer Socket is of UIB.

              For more information on how to create DMA channel please look into the example firmware that come along with FX3 SDK.

              C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbi2cdmamode

              This is an example with performs i2c transfer using DMA channel.

               

               

              Thanks & Regards

              Abhinav

              • 4. Re: Use two types of DMA Channel?
                lk960825_3660966

                Hi Abhinav:

                 

                     Thank you for your reply.

                     Well,I have refered to example cyfxusbi2cdmamode and cyfxusbuartLpdmamode.But this are not what I want.I have open up two memory spaces in SRAM,one is named RX_Buffer which save received data from external ARM,the other one is named TX_Buffer which save send data.also we pull out the FX3's RX and TX pins to ARM.

                     In example cyfxusbuartLpdmamode.

                    LP.png

                 

                     what I need:

                     Need.png

                 

                    Can you tell me if I can fulfill this requirement?If I can, what should I do in DMA config and how to get received buffer or send data?

                 

                Best Regards

                Luca L

                • 5. Re: Use two types of DMA Channel?
                  lk960825_3660966

                  Hi Abhinav:

                   

                       I have solved this problem. Thank you!

                   

                  Best Regards

                  Luca L