- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Labels:
-
PSoC 6 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Ekta_N ,
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @RodolfoGL ,
Test case I am using to evaluate my Dual USB to UART bridge driver application:
EVK: CY8CKIT-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:
- Single byte transfer using teraterm: Working Fine
- Sending 4KB file using Hercules terminal app: Working fine
- Modbus Master Slave communication:
- 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
- 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)
- both UART com port as Modbus master & both USB CDC com port as Modbus Slave: Working Fine
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have already checking 'if (USBD_CDC_GetNumBytesRemToWrite(usb_cdcHandle[port]) == 0)' before 'USBD_CDC_Write(usb_cdcHandle[port], pData, length, -1); '
Is there any other checks i need to add?
I have another question.
0:000 PANIC: Could not allocate endpoint (you can increase USB_NUM_EPS)
0:000 PANIC: Could not allocate endpoint (you can increase USB_NUM_EPS)
Is there any way that i can get have 4 Bulk OUT Endpoints & 4 Bulk IN Endpoints in PSoC62 using emUSB-device?