Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 6 Forum Discussions

riteshEB
Level 1
Level 1
5 sign-ins First reply posted First question asked

Is there any sample application available for PSoC6 device in Modus Toolbox IDE which demonstrate USB-CDC to UART bridge functionality.

I have created an application and its working but I am facing reliability issues with higher frame size and higher data transmission rate. 

How to use SCB UART with RX DMA when receive frame size is not fixed? 

Can i use emUSB-device cdc with DMA? 

 

0 Likes
5 Replies
Ekta
Moderator
Moderator
Moderator
250 solutions authored 100 likes received 250 sign-ins

Hi @riteshEB 

We do not have a combined application with both USB-CDC and UART functionality in the same application but there are separate code examples for each of them:

1. https://github.com/Infineon/mtb-example-psoc6-usb-cdc-echo
2. https://github.com/Infineon/mtb-example-psoc6-uart-transmit-receive-dma

Could you provide more information regarding your application? I guess as per your question that you would be receiving data via USB port (using CDC class) and are transferring that data to the UART FIFO.

Is the size of data coming via USB variable? How is it decided that the data needs to be transferred to the UART fifo?

What is the issue you are facing with higher frame size and data rates? Based on this we could suggest possible solutions to the issue?

How to use SCB UART with RX DMA when receive frame size is not fixed: Based on the appliation it might be possible to configure the chain two DMAs to do byte by byte when we have data in the UART FIFO and disable the DMA when the data is not there.

Can i use emUSB-device cdc with DMA?
Do you mean if you could use the PSoC 6 USB device (configured for CDC class) with DMA - yes it is possible to do so.


Best Regards
Ekta

 

 

0 Likes
riteshEB
Level 1
Level 1
5 sign-ins First reply posted First question asked

Hi @Ekta ,

Thanks for the reply.

My application is like 2x USB to UART bridge. USB is configured with 2 CDC instances. Each USB CDC instance is associated with one UART port for bridge application. Receiving data via USB port (using CDC class) and are transferring that data to the UART FIFO and vice versa. So data coming from USB as well as UART is variable. 


configure the chain two DMAs to do byte by byte when we have data in the UART FIFO and disable the DMA when the data is not there.

How can i check whether data is not there? enable a timer and check dma register? It would be nice if you could share some code snippet? 

use the PSoC 6 USB device (configured for CDC class) with DMA - yes it is possible to do so.

Can you share some detail how to configure? As there is not additional configuration available for emUSB-Device driver.  Can I use DMA directly for USB CDC RX to UART TX and UART RX to USB CDC TX?

riteshEB_2-1672641222168.png

0 Likes
RodolfoGL
Employee
Employee
250 sign-ins 5 comments on KBA First comment on KBA

Can you elaborate a bit more about your "reliability issues" with higher frame size and higher data transmission rate?

The emUSB-device CDC is limited to 64 bytes, so if the host sends a packet with more than 64 bytes, the driver will split it in chunks of 64 bytes.

Because of that, it might not be worth to use the DMA, since the time it takes to setup the DMA and trigger it, will be the same as writing/reading a few bytes to/from the UART FIFO.

The USB will be probably the bottle neck in your application, specially if you are transmitting with UART at higher than 1Mbps. 

0 Likes

Hi @RodolfoGL ,

Test case I am using to evaluate my Dual USB to UART bridge driver application: 

EVKCY8CKIT-062S2-43012

USB Configuration: 2 CDC interface (emUSB-Device library) (Connected USB port of EVK to host PC)

USB Tx API: USBD_CDC_Write(usb_cdcHandle[port], pData, length, -1);

USB Rx API: USBD_CDC_Receive(usb_cdcHandle[port], pData, length, -1):

UART Configuration: 2 UART port SCB0 & SCB1 (115200 baud) (Connected with host PC using 2 USB to UART module)

UART Tx using DMA

UART Rx API: Cy_SCB_UART_GetArray(UART_0_HW, pData, length);

Host PC : 2 USB CDC COM ports and 2 UART COM ports are open in PC using serial terminal applications. Each CDC port is associated with single UART port for bridge application.

Test Scenarios:

  1. Single byte transfer using teraterm:  Working Fine
  2. Sending 4KB file using Hercules terminal app: Working fine
  3. Modbus Master Slave communication:
    1. both UART com port as Modbus master & both USB CDC com port as Modbus Slave: Working Fine
      • Reading 125 Holding register with 1ms scan rate (255 Bytes)
      • UART Rx 8 Bytes
        USB Tx 8 Bytes
           
        USB Rx 255 Bytes
        UART Tx 255 Bytes
    2. both USB CDC com port as Modbus Master & both UART com port as Modbus Slave: Having Issues
      • Issue 1: Reading 10 Holding register with 100ms scan rate (25 Bytes). sometimes getting timeout for Modbus request. (1 timeout in 20-30 request). At timeout condition, USBD_CDC_Write() seems not transmitting any data. I have verified this using serial port analyzer tool.
      • USB Rx 8 Bytes
        UART Tx 8 Bytes
           
        UART Rx 25 Bytes
        USB Tx 25 Bytes
      • Issue 2: Reading 30-125 Holding Register  (65 to 255 Bytes): MCU soft reset or CDC port hangs (not getting any CDC Rx or Tx data)

I have tried various CDC blocking not blocking APIs also added WaitFor() APIs but getting the same  behaviors. 

Let me know if you want any further clarification. 

0 Likes
RodolfoGL
Employee
Employee
250 sign-ins 5 comments on KBA First comment on KBA

At least on the original mtb-example-usb-device-cdc-echo, I find that sending more than 64 bytes make the device irresponsive. After some debugging, we need to place some overflow check on the write buffer.

Perhaps review your code to see if any overflow condition on the write buffer is occurring. 

I internally filed a ticket to get the code example fixed.

0 Likes