cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

ElTa_4521156
New Contributor II

Hi,
I am trying to change the descriptor of usbuart example to access to data in cdc and vendor at the same time.
I mean when I am sending data through uart to /from usb , I have access to data by control center as well. So I added vendor descriptor to that example with the same DMA channels, but nothing comes up in CC. Should I change anything else?
In device manger I can see that as a com port, but nothing appears in CC.
I attached the modified descriptor file.
Thanks

0 Likes
1 Solution
Rashi_Vatsa
Moderator
Moderator

Hello,

Please refer to this KBA  Adding Communication Device Class Interface to FX3... - Cypress Developer Community  

As per the requirement vendor  + CDC interface , you can follow the steps mentioned in this KBA or use the descriptor file of the firmware shared with the KBA. The descriptor file has the same configuration as per your requirement.

The descriptor file shared by you doesn't enumerate as shown at your end. Please let me know which steps did you follow to bind the driver manually. 

The device will come up in control center only when the cypress driver (cyusb3.sys) binds to the device.

Regards,
Rashi

View solution in original post

0 Likes
19 Replies
Rashi_Vatsa
Moderator
Moderator

Hello,

Please refer to this KBA  Adding Communication Device Class Interface to FX3... - Cypress Developer Community  

As per the requirement vendor  + CDC interface , you can follow the steps mentioned in this KBA or use the descriptor file of the firmware shared with the KBA. The descriptor file has the same configuration as per your requirement.

The descriptor file shared by you doesn't enumerate as shown at your end. Please let me know which steps did you follow to bind the driver manually. 

The device will come up in control center only when the cypress driver (cyusb3.sys) binds to the device.

Regards,
Rashi

View solution in original post

0 Likes
ElTa_4521156
New Contributor II

Hi,
I replaced the descriptor of that KBA in usbuart example. I only did one change: I used the same address for EP in cdc and vendor (CY_FX_EP_CONSUMER/CY_FX_EP_PRODUCER), as I want to use from these endpoints in both states.
I followed the steps on the mentioned KBA for binding driver manually. but after step3, my device manager shows figure 3 again not figure 4.
So I followed the step 1-14 at the end of the page. I attached my device manager image. But still nothing in CC.
(for  step 2 "To bind the Cypress cyusb3 driver properly, uninstall the previously bound driver."
I did uninstall device from device manager.)

Thanks

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

EP in cdc and vendor (CY_FX_EP_CONSUMER/CY_FX_EP_PRODUCER), as I want to use from these endpoints in both states.

>>  Please do no use the same endpoints for both the interface i.e. CDC vendor. Different endpoints should be used for both interfaces. Please let me know which DMA channel is used for UART > USB. If possible, please share the firmware file for us to check.

Regards,
Rashi
0 Likes
ElTa_4521156
New Contributor II

Hi,
Before I try my example, now I tried the example SlaveFifoSync in https://community.cypress.com/t5/Knowledge-Base-Articles/Adding-Communication-Device-Class-Interface...
and in step 4 I followed these steps: https://community.cypress.com/t5/Knowledge-Base-Articles/Trouble-Shooting-Guide-for-the-FX3-FX3S-CX3...

But I got this: "windows was unable to install your fx3" and I couldn't get Cypress FX3 USB StreamerExample Device.

Thanks

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

Please follow the steps mentioned for manual driver binding in the attached file and let me know if it works.

Regards,
Rashi
0 Likes
ElTa_4521156
New Contributor II

Hi,
Thank you. Now I could see both serial port and  Cypress FX3 USB StreamerExample Device in device manager.

I added vendors descriptor to usbuart example(used from the cyfxslfifousbdscr and also change the main c file), now it comes up in CC. But I have two other problems:

1- Before changing the 
descriptors, I tested usbuart example by opening two teraterm pages. it was working. After changing the descriptor, it doesn't work in teraterm.

2- My goal is I could send data  from CC to serial pins and vice versa, at the same time I could do the same from tera term. I added two EPs for vendor descriptors. but I don't know how can make them related to the existing DMA. I added two different DMA channels for these EP. but I have no idea for flowing data. should I copy one Dma to another?

I attached the firmware.
Thanks

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

Glad to hear that the device comes up as CDC + UART

1- Before changing the descriptors, I tested usbuart example by opening two teraterm pages. it was working. After changing the descriptor, it doesn't work in teraterm.

>> I tried programming the firmware you shared to FX3 and it works. (results attached)

My goal is I could send data  from CC to serial pins and vice versa, at the same time I could do the same from tera term. I added two EPs for vendor descriptors. but I don't know how can make them related to the existing DMA.

>> Can you please let me know how are planning to send data from both CDC and vendor interfaces. Is it in PingPong manner or is it completely random.

If its, random then UART in DMA mode cannot be used as UART has only one producer and consumer socket. In that case if DMA channel between UART (prod) > USB_cdc (cons) is created, the DMA channel between UART(prod) > USB_vendor cannot be created simultaneously. Out of the two mentioned, only one DMA channel can be created at a time.

Or else you can use UART in register mode and create MANUAL OUT DMA channels to send the data from UART to specific USB interface. Similarly, MANUAL IN channels for vice versa.

If the data is to be sent in interleaved manner then One to Many and Many to one DMA channels can be created for data transfer from UART to USB (CDC & vendor) and USB (CDC & vendor) to UART 

Please let me know your application so that I can help with the firmware modifications

Regards,
Rashi
0 Likes
ElTa_4521156
New Contributor II

Hi, 
Thanks for your reply.
1-When I used the main usbuart example(VID=0x08, 0x00), I can see that as COM11 in device manager and works, in the same project when I replace the descriptor file with the cdc-vendor one, It comes up with COM9(VID=0xf1, 0x00) or COM12(VID=0x08, 0x00) and it doesn't work. I  reinstall drivers but still doesn't work.

2- yes, it is random. So you mean that it is better that I use from uartlpregmode and add MANUAL OUT/in DMA channels to that then switch between Ep?  Sorry, It is not clear for me how the  data flow would be  from uart to dma and then EP. is there any example to help me on that?

Thank you

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

Please find my comments below

1 - Out of the two com ports, COM9(VID=0xf1, 0x00) is the USB CDC interface and COM12(VID=0x08, 0x00)  is the UART port. Is that correct? Please check if there are any failure or if the data is received by fx3 . As mentioned in my previous post, the firmware works fine on FX3 explorer kit

2-  UartLpMode example loopbacks the data over UART. For you application you can use UART in register mode and create MANUAL IN and MANUAL OUT DMA channel for sending/receiving data to /from USB. For UART to USB transfer, when the data is received form UART, the data can be copied to a DMA buffer and can be sent to USB via MANUAL OUT channel and vice versa. This is because the data is not to be sent in interleaved fashion to both USB interface (CDC + vendor) and two DMA channels with same producer socket (UART_PROD) cannot be used simultaneously. We do not have similar example firmware but we can help you with the firmware modification

Please let me know if you have queries on this

Regards,
Rashi
0 Likes
ElTa_4521156
New Contributor II

Hi,
1- No, in the same project when I use VID=0xf1, 0x00 it appears as COM9 and when I use VID=0x08, 0x00 it appears COM12 in device manager.
Ok I will check your comments and let you know the result  soon.
Thanks

0 Likes
ElTa_4521156
New Contributor II

Hi,
Thanks. I used UART in register mode and create MANUAL IN and MANUAL OUT DMA channel for sending/receiving data to /from USB . It almost works , but I have a problem in sending data.
I need to send/receive data byte-by-byte because of undefined packet length.
I put CY_FX_UARTIn_BUF_SIZE =1.  I send a byte from Teraterm and received it in CC (Tranfer Data In). But I lost data if I enter more than 3 bytes in Teraterm before reading in CC. For example, If I enter 123456 then read in CC, I read 1 / 2 / 3 / error997. then if I resume sending data in Tera term with 789abc, now I read 7/8/9/error997. so I miss 456 and abc.

In CyFxUartUsbApplnCallback, I try to send data which I received from Tetaterm.  

Thanks

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

Please let me know if CyU3PDmaChannelGetBuffer or CyU3PDmaChannelCommitBuffer fails when the data is lost.

From the firmware I see that only 1 buffer is used for the CY_U3P_DMA_TYPE_MANUAL_OUT channel.  Please try increasing the DMA buffer count and let me know if the problem still exists. If the DMA buffers are not consumed by the USB host, the CyU3PDmaChannelCommitBuffer is expected to fail to error code 0x47 (71). Please let me know if CyU3PDmaChannelCommitBuffer fails. Also check if the below loop is entered for the 4 time i.e. if 4th byte is received by FX3 when data is sent from tera term to FX3

if (UartDataCount == CY_FX_UARTIn_BUF_SIZE)
{ ....}

Regards,
Rashi
0 Likes
ElTa_4521156
New Contributor II

Hi,
I increased the DMA buffer count, the problem still exists, but after a few more bits.
I changed  this callback a bit(I copied below), now, in debug mode after receiving the second byte,  it stuck at CyU3PDmaChannelGetBuffer and nothing can be seen. and I see "error Target not available."
Also, I see CY_U3P_UART_ERROR_NAK_BYTE_0 in uart callback event, although I can see the bytes are correct and have stop buts.

static void
CyFxUartUsbApplnCallback (
CyU3PUartEvt_t evType,
CyU3PUartError_t evStatus)
{ uint8_t rxData;
uint32_t count;
CyU3PReturnStatus_t status;
CyU3PDmaBuffer_t dmaInBuf;
if (evType == CY_U3P_UART_EVENT_RX_DATA)
{
do
{
/* Keep reading the incoming data into the buffer, as long as we have space. */
count = CyU3PUartReceiveBytes (&rxData, 1, &status);
if (count != 0)
{
/* Just drop the data if the buffer is already full. */
if (UartDataCount < CY_FX_UARTIn_BUF_SIZE)
{
UartInDataBuffer[UartDataWrPtr] = rxData;
UartDataWrPtr++;
if (UartDataWrPtr == CY_FX_UARTIn_BUF_SIZE)
UartDataWrPtr = 0;
UartDataCount++;
}
if (UartDataCount == CY_FX_UARTIn_BUF_SIZE)
{ status = CyU3PDmaChannelGetBuffer (&glInChHandle, &dmaInBuf, CYU3P_WAIT_FOREVER);// MANUAL_OUT
if (status != CY_U3P_SUCCESS)
{
CyU3PDmaChannelReset (&glInChHandle);
CyU3PDmaChannelSetXfer (&glInChHandle, 0);
CyFxAppErrorHandler(status);
}
else
{
CyU3PMemCopy (dmaInBuf.buffer, (uint8_t*)UartInDataBuffer, CY_FX_UARTIn_BUF_SIZE);
status = CyU3PDmaChannelCommitBuffer (&glInChHandle, CY_FX_UARTIn_BUF_SIZE, 0);
}
UartDataCount = 0;
}
}
} while (count != 0);
}
}

 
If I used CyU3PDmaChannelGetBuffer before do-while loop, I got error 71 in CyU3PDmaChannelCommitBuffer .



Also, I tried in a thread, but in that case only send two bytes and stuck:

I used this code in Callback:
if (evType == CY_U3P_UART_EVENT_RX_DATA)
{
if (UARTIn_ready == CyFalse)
{
do
{
count = CyU3PUartReceiveBytes (&rxData, 1, &status);
UartInDataBuffer[0] = rxData;
if (count != 0)
{
CyU3PEventSet (&UartUsbAppEvent, UART_RECEIVE_DATA_EVT, CYU3P_EVENT_OR);
UARTIn_ready = CyTrue;
}
} while (count != 0);
}
}

and this part in the thread:

status = CyU3PEventGet (&UartUsbAppEvent, UART_RECEIVE_DATA_EVT, CYU3P_EVENT_OR_CLEAR, &evStat, CYU3P_WAIT_FOREVER);
if(UARTIn_ready)
{
status = CyU3PDmaChannelGetBuffer (&glInChHandle, &dmaInBuf, CYU3P_WAIT_FOREVER);
CyU3PMemCopy (dmaInBuf.buffer, (uint8_t*)UartInDataBuffer, 1);
status = CyU3PDmaChannelCommitBuffer (&glInChHandle, 1, 0);
if (status != CY_U3P_SUCCESS)
{
CyFxAppErrorHandler(status);
}
else
{
UARTIn_ready = CyFalse;
}
}



Thanks

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

Please let me know how many DMA buffers are used currently.

Also, let me know is any errors are seen for the second implementation. The second implementation seems fine as use events to communicate. 

Please let me know if any of the APIs fail in the second implementation. Also, try configuring the RX timeout value to 1 using CyU3PUartSetTimeout API.

Regards,
Rashi
0 Likes
ElTa_4521156
New Contributor II

Hi,

1-
CY_U3P_DMA_TYPE_MANUAL_OUT : size 32 count 1
CY_U3P_DMA_TYPE_MANUAL_IN:      size 32 count 1
I increased the DMA buffer count, the problem still exists.

2- The second implementation FW is attached. it only received 2 bytes inn CC and nothing after that. my codes are in : UartUsbAppThread_Entry  / CyFxUartUsbApplnCallback.
I couldn't see any API error, as I set breakpoint in  Thread_Entry, but I  get "Error: Unable to set 32 bit software breakpoint"

3- I set the timeout to 1, no effect

My goal is sending data from Teraterm,  then receiving that in CC byte by byte.

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello Elham,

The firmware you shared is working fine at my end.

I tried sending "123456" from tera term and received the bytes on control center bytes by byte.

cc_byte_by_byte.PNG

The only change I did to the firmware is as below. If 6 bytes are being sent from the UART and the DMA buffers are not available as the consumer socket (USB) has not consumed the buffers yet, the get buffer API will fail and the data cannot be sent to USB

dmaCfg.size = 32;
dmaCfg.count = 10;

Please configure the DMA buffer count high enough such that DMA buffers are available to receive the data.

Regards,
Rashi
0 Likes
ElTa_4521156
New Contributor II

Hi,
Thank you for your reply. Yes, you are right. 
In this example when I enter less than 11 bytes and read in CC, everything is ok. But if I enter more than 11 bytes, for example 12 bytes, and start to read from CC, it doesn't work ever after (Error Code:997). I have to replug and reprogram FX3 for continuing
Does it mean that never I should let to DMA be written more than 11 in this example otherwise this situation happens?

If yes, do I need a handshaking if I send an stream over UART and read in CC to control the speed and prevent stucking?

Thanks

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

Please find my comments below

Does it mean that never I should let to DMA be written more than 11 in this example otherwise this situation happens?

>> It is recommended to consume the DMA buffers before all of them are filled completely. If the data is not consumed from the USB side the commit buffer failure will be seen and error 997 on the CC. Once the commit buffers are seen, it is recommended to reset the channel and start the transfers again.

If yes, do I need a handshaking if I send an stream over UART and read in CC to control the speed and prevent stucking?

>> Yes, UART flow control can be used in register mode. You can track the DMA buffers in the firmware, if the DMA buffer is committed successfully, the tracker (global variable) can be increased by one and if the DMA buffer is consumed  by USB it can be decremented. 

Based on the tracker value, the CyU3PUartReceiveBytes should be called. If all the DMA buffers are filled then CyU3PUartReceiveBytes should not be called which will in turn fill the UART FIFO and flow control lines will inform the UART transmitter to stop the transfers.

Please let me know if any queries on this.

Regards,
Rashi
0 Likes
ElTa_4521156
New Contributor II

Thanks Rashi for your help.

0 Likes