FX3, UART to USB transfer response time

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

cross mob
lock attach
Attachments are accessible only for community members.
LP1
Level 2
Level 2
5 likes given 10 replies posted 10 sign-ins

Hello,

I've still been working for an issue of the post.

Thank you for Infineon's supports for the post. 
The topic was closed while I was working on some another FPGA issues on my product but 
 I found that the reason of the issue was confliction between transfers of two end points.
It seems that a GPIF II -> USB Bulk IN transfer is interrupted by a UART -> USB Bulk IN transfer.

 

------------
My product uses several Bulk IN channels,

1) GPIF II -> USB (to transfer large amount of data from external FPGA with high transfer rate continuously) 
2) GPIF II -> USB (to transfer up to 32KB data from external FPGA occasionally) 
3) UART -> USB  (to transfer 32bytes fixed length short data from external MCU occasionally)
4) FX3 -> USB  (to transfer debug print messages generated in FX3 occasionally)

These channels are polled by PC application asynchronously.

 

I found that attempts of XferData() for UART -> USB channel always ended with timeout. 
The external MCU sends packets only occasionally and the FX3's buffer is empty most time.
No timeout is seen when a packet is sent from the MCU and FX3's buffer is filled.

I checked to call XferData() separately for each one of these 4 channels and
only UART -> USB channel had this issue.
(and  the issue of the post is solved by not using the UART -> USB channel and GPIF II->USB channel simultaneously)

I would like to confirm that

1) Is this behavior of UART->USB port normal?
Or should the FX3 response ZLP (or something) immediately when the buffer is empty?

2) Is it possible to use XferData() "by two or more threads" "asynchronously"
"for different endpoints" of "one FX3 device"?
I read KBA94607 and it's possible with my understanding, but it's still not clear for me.

------------

I attach a wireshark log of USB transfer attempts.
The address of my FX3 product is 1.14. The UART->USB channel is 1.14.3 (EP 0x83).
Most polling attempts end with timeout in the log, however, 
line 326 - 347 are intended data transfers and no problem is seen.

1) GPIF II -> USB,  4)FX3->USB channels are not activated to clarify the issue. 
Address 1.14.2 is the 2)GPIF II->USB channel. 

The UART channel setting is as shown below.

----------
UART Initialization

apiRetStatus = CyU3PUartInit();
if (apiRetStatus != CY_U3P_SUCCESS)
{
DebugPrint("UART_Initialize, CyU3PUartInit Failed, Error code = %d\n", apiRetStatus);
CommandErrorHandler(apiRetStatus);
}


//UART Settings
CyU3PMemSet ((uint8_t *)&uartConfig, 0, sizeof (uartConfig));
uartConfig.baudRate = CY_U3P_UART_BAUDRATE_115200;
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;

apiRetStatus = CyU3PUartSetConfig (&uartConfig, NULL);

//Set the UART transfer to a really large value.
apiRetStatus = CyU3PUartTxSetBlockXfer (0xFFFFFFFF);

//TEST
CyU3PUartSetTimeout(1,1); // this did not affect the behavior of the channel

 

-------------
EP Initialization

CyU3PEpConfig_t epCfg;
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

CyU3PMemSet ((uint8_t *)&epCfg, 0, sizeof (epCfg));
epCfg.enable = CyTrue;
epCfg.epType = CY_U3P_USB_EP_BULK;
epCfg.burstLen = 0; //Burst length 1
epCfg.streams = 0;
epCfg.pcktSize = size;

apiRetStatus = CyU3PSetEpConfig(EP_COMMAND_CONSUMER, &epCfg);
if (apiRetStatus != CY_U3P_SUCCESS)

CyU3PUsbFlushEp(EP_COMMAND_CONSUMER);


--------------
DMA Initialization

CyU3PDmaChannelConfig_t dmaCfg;
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

dmaCfg.size = 32;
dmaCfg.count = 8;
dmaCfg.prodSckId = CY_U3P_LPP_SOCKET_UART_PROD;
dmaCfg.consSckId = EP_COMMAND_CONSUMER_SOCKET;
dmaCfg.dmaMode = CY_U3P_UIB_SOCKET_CONS_3;
dmaCfg.notification = 0;
dmaCfg.cb = NULL;
dmaCfg.prodHeader = 0;
dmaCfg.prodFooter = 0;
dmaCfg.consHeader = 0;
dmaCfg.prodAvailCount = 0;

apiRetStatus = CyU3PDmaChannelCreate (&glCommandIN_DMA_Handle,
CY_U3P_DMA_TYPE_AUTO, &dmaCfg);

apiRetStatus = CyU3PDmaChannelSetXfer (&glCommandIN_DMA_Handle, 0);

 

0 Likes
1 Solution
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

Please find my comments for your questions below:
1) Is this behavior of UART->USB port normal?
Or should the FX3 response ZLP (or something) immediately when the buffer is empty?

The behavior shown by FX3 is normal. When there is no data available in an endpoint, the xferdata will return timeout. It is not possible for a bulk endpoint of FX3 to respond with ZLP when the buffer is empty.

2) Is it possible to use XferData() "by two or more threads" "asynchronously"
"for different endpoints" of "one FX3 device"?

Yes, this is possible. The KBA mentions that simultaneous data transfer through IN and OUT endpoints are not possible. Even if the host application tries to asynchronously call xferdata in different threads, the actual transfers will be time multiplexed on the USB bus (i.e the requests are queued one by one in the bus). 

A better approach that I can recommend is:

1. Use a global variable in firmware to check if there is data available with the UART-USB channel. The value of global variable can be set when the data is available in the UART-USB channel. It can be cleared as soon as the data is not available in UART-USB channel.

2. From the host application, issue a vendor command to check the value of this global variable in one thread. 

3. If the status of global variable indicates that there is data available in UART-USB channel, then use synchronous xferdata call to read the data from the endpoint asserted with UART-USB channel. This is because asynchronous xferdata is used for large data transfers. For small data transfers, synchronous xferdata would be enough.

4. In a different thread, you can use asynchronous xferdata to read data from the endpoint corresponding to GPIFII-USB endpoint.

By following the approach given above, the timeout issue due to non-availability of data should be resolved.

Best Regards,
Jayakrishna

View solution in original post

4 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

Please find my comments for your questions below:
1) Is this behavior of UART->USB port normal?
Or should the FX3 response ZLP (or something) immediately when the buffer is empty?

The behavior shown by FX3 is normal. When there is no data available in an endpoint, the xferdata will return timeout. It is not possible for a bulk endpoint of FX3 to respond with ZLP when the buffer is empty.

2) Is it possible to use XferData() "by two or more threads" "asynchronously"
"for different endpoints" of "one FX3 device"?

Yes, this is possible. The KBA mentions that simultaneous data transfer through IN and OUT endpoints are not possible. Even if the host application tries to asynchronously call xferdata in different threads, the actual transfers will be time multiplexed on the USB bus (i.e the requests are queued one by one in the bus). 

A better approach that I can recommend is:

1. Use a global variable in firmware to check if there is data available with the UART-USB channel. The value of global variable can be set when the data is available in the UART-USB channel. It can be cleared as soon as the data is not available in UART-USB channel.

2. From the host application, issue a vendor command to check the value of this global variable in one thread. 

3. If the status of global variable indicates that there is data available in UART-USB channel, then use synchronous xferdata call to read the data from the endpoint asserted with UART-USB channel. This is because asynchronous xferdata is used for large data transfers. For small data transfers, synchronous xferdata would be enough.

4. In a different thread, you can use asynchronous xferdata to read data from the endpoint corresponding to GPIFII-USB endpoint.

By following the approach given above, the timeout issue due to non-availability of data should be resolved.

Best Regards,
Jayakrishna
LP1
Level 2
Level 2
5 likes given 10 replies posted 10 sign-ins

I'll try to implement these functions you mentioned.

Thank you for your fast and clear answers!

0 Likes
LP1
Level 2
Level 2
5 likes given 10 replies posted 10 sign-ins

I implemented the vendor request to check the UART DMA buffer is ready or not, and problems are completely solved!
It's 4 years long project for this product and now the product is ready to be deployed.

Thank you very much!

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi,

We are glad to hear that our suggestions were helpful for you.

Best Regards,
Jayakrishna
0 Likes