11 Replies Latest reply on Feb 7, 2019 8:55 AM by antac_1095701

    How to send debug data out an existing dma channel

    antac_1095701

      I have a USB/UART bridge implemented with a MANUAL dma channel. The producer socket is the UART and the consumer is a USB out EP. I want to send debug messages to this consumer socket so that the terminal on the receiving PC will show these messages. The UART/USB bridge currently works (I am testing using a UART loopback). I found in another thread that the CyU3PDmaChannelSetupSendBuffer command can be used to send a different buffer to the consumer socket of a DMA channel.

       

      I've tried this approach but I am not seeing any of the data sent via this method being sent. The UART/USB bridge loopback works fine. I have two terminals open on my pc. One is the USB/UART bridge and the other is connected to the UART RX/TX pins of the FX3. I can type in one terminal and watch the characters appear in the other going both directions.

       

      Is there something I am missing with the parameters of the DMA channel (buffer size, count, type) that would affect the CyU3PDmaChannelSetupSendBuffer API call?

      Is there an approach where I can configure firmware logging capability with CyU3PDebugInit to set the socket and still use the CyU3PDebugPrint() function?

        • 1. Re: How to send debug data out an existing dma channel
          SrinathS_16

          Hello,

           

          - Please let us know why you have used the DMA consumer as USB OUT endpoint.

          - I understand that you are willing to send the debug prints over to USB using the UART port of FX3 which can be viewed on a terminal application like TeraTerm. In case my understanding is wrong, please correct me and explain yours with a block diagram.

          - Kindly, post snippets of firmware code that performs the UART initialisation, configuration and data transfer.

           

          Best regards,

          Srinath S

          • 2. Re: How to send debug data out an existing dma channel
            antac_1095701

            I misspoke - it us a BULK-IN endpoint (0x85), not a BULK_OUT endpoint. This is a VCOM port so I do not want to send the data to the physical RX/TX UART pins of the FX3. I want the data to go to the virtual COM Port (enumerates as USB serial device on the post PC). The end points and code are based on the USB UART Bridge sample project from Cypress.

             

            This is the DMA channel creation

                dmaCfg.size         = 32;

                dmaCfg.prodSckId    = CY_FX_EP_UART_PROD_SOCKET;

                dmaCfg.consSckId    = CY_FX_EP_USB_CONS_SOCKET; ;//(CY_U3P_UIB_SOCKET_CONS_5)

                dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT;

                dmaCfg.cb           = CyFxUSBUARTDmaCallback;

             

             

                apiRetStatus = CyU3PDmaChannelCreate (&glChHandleUarttoUsb, CY_U3P_DMA_TYPE_MANUAL, &dmaCfg);

                if (apiRetStatus != CY_U3P_SUCCESS)

             

            The consumer end point is part of a CDC device (see interface descriptor below). The CDC device has 2 interfaces, an interrupt USB ep and a bulk-IN ep (for data transfer to the host). I am trying to send the data to the bulk-IN endpoint. This seems to match other examples where the CyU3PDmaChannelSetupSendBuffer () API function is used (USBFlashProg and USBHost examples from Cypress).

             

            Bulk-IN and Bulk-OUT descriptors.

                /* Data Interface Descriptor */

                0x09,                           /* Descriptor size */

                CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */

                0x01,                           /* Interface number */

                0x00,                           /* Alternate setting number */

                0x02,                           /* Number of endpoints */

                0x0A,                           /* Interface class: Data interface */

                0x00,                           /* Interface sub class */

                0x00,                           /* Interface protocol code */

                0x00,                           /* Interface descriptor string index */

             

             

                /* Endpoint Descriptor(BULK-PRODUCER) */

                0x07,                           /* Descriptor size */

                CY_U3P_USB_ENDPNT_DESCR,        /* Endpoint descriptor type */

                CY_FX_EP_UART_PROD,             /* Endpoint address and description */ (0x05, data from host to FX3)

                CY_U3P_USB_EP_BULK,             /* BULK endpoint type */

                0x00,0x02,                      /* Max packet size = 512 bytes */

                0x00,                           /* Servicing interval for data transfers */

             

             

                /* Endpoint Descriptor(BULK- CONSUMER) */

                0x07,                           /* Descriptor size */

                CY_U3P_USB_ENDPNT_DESCR,        /* Endpoint descriptor type */

                CY_FX_EP_USB_CONS,             /* Endpoint address and description */  (0x85, data from FX3 to host)

                CY_U3P_USB_EP_BULK,             /* Bulk endpoint type */

                0x00,0x02,                      /* Max packet size = 512 bytes */

                0x00,                            /* Servicing interval for data transfers */

            • 3. Re: How to send debug data out an existing dma channel
              SrinathS_16

              Hello,

               

              Can you please share the firmware project to test at my end?

               

              Best regards,

              Srinath S

              • 4. Re: How to send debug data out an existing dma channel
                antac_1095701

                Ok. What is the preferred method for sharing a project? I don't want to attach directly to this forum thread. Is there a secure transfer ftp site?

                • 5. Re: How to send debug data out an existing dma channel
                  SrinathS_16

                  Hello,

                   

                  Please share the firmware project to Srinath.S@cypress.com.

                   

                  Best regards,
                  Srinath S

                  • 6. Re: How to send debug data out an existing dma channel
                    SrinathS_16

                    Hello,

                     

                    Based on your firmware, one of the composite interface comes up as a CDC class device and enumerates as a COM port. Your firmware project has a DMA channel between the UART producer and the USB consumer. So, the data transfer happens between the UART producer socket and the USB consumer socket. The UART producer socket internally refers to the RX/TX pin interface of the UART block of FX3. Hence, any data that is sent on the UART TX/RX pins of FX3 will be directed to the USB consumer socket (IN endpoint 0x85 in your case). This is the expected functionality and is working fine. Please let me know what is your expectation.

                     

                    Best regards,

                    Srinath S

                    • 7. Re: How to send debug data out an existing dma channel
                      antac_1095701

                      Srinath,

                        My question is not about the data flowing from the UART TX/RX pins to the USB consumer socket. I would like debug message from the FX3 (ie calls to CyU3PDebugPrint) to also be sent to the USB consumer socket. In the thread linked below

                       

                      Re: Any way to use CyU3PDebugInit on an already initialized socket?  I want debug output and other DMA output to both be directed to the UART.

                       

                      The user is trying to send debug messages to an already initialized socket, though in their case the socket is the UART consumer. In my case, the already initialized socket is the USB consumer as part of the CDC device. However, the data I am committing using the CyU3PDmaChannelSetupSendBuffer() api call is not appearing on the VCOM port.

                       

                      Does that clarify my issue with you?

                      • 8. Re: How to send debug data out an existing dma channel
                        SrinathS_16

                        Hello,

                         

                        Please find the attached project. I have modified it to include the SendDebugMessage() function which sends the user defined buffer to the UART consumer overriding the existing DMA channel. This function uses the CyU3PDmaChannelSetupSendBuffer() API which overrides the producer socket used in the DMA channel and the user defined buffer is sent to the consumer socket.

                         

                        Points to note:

                        - Before using the CyU3PDmaChannelSetupSendBuffer(), the channel must be in the CONFIGURED state. The CyU3PDmaChannelReset() API has been used to put the channel in the CONFIGURED state.

                        - While exiting the SendDebugMessage() function, the CyU3PDmaChannelSetXfer() API has been called again to initiate the normal DMA operation.

                        - Calling SendDebugMessage() function before the CyU3PDmaChannelSetXfer() API in the CyFxUSBUARTAppStart() function will result in failure of the CyU3PDmaChannelSetXfer() API. Hence, the SendDebugMessage() function can be called only after the CyU3PDmaChannelSetXfer() API in the CyFxUSBUARTAppStart() function.

                         

                        Please test the firmware at your end and let me know if this suits your requirement.

                         

                        Best regards,

                        Srinath S

                        • 9. Re: How to send debug data out an existing dma channel
                          antac_1095701

                          Thank you. Adding the CyU3PDmaReset() call before the SetupSendBuffer() made this begin to work on my end. I will search through the TRM and API Guide for more information about dma channel states and the CONFIGURED state. Is there a way to check this state manually? What are the other states besides configured?

                          • 10. Re: How to send debug data out an existing dma channel
                            SrinathS_16

                            Hello,

                             

                            Please look at section 5.17.4.9 and 5.17.3.6 of the FX3APIGuide.PDF file for details on the API to get the current status and the different channel states.

                             

                            Best regards,

                            Srinath S