- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am sending/receiving data to/from UART to bulk end points. Every thing works well when I use control center.
But when I use the same setup with cyusb_linux instead of CC, I can only send data. When I hit the receive button, I got error -7 in cyusb_bulk_transfer (on_pb6_rcv_clicked). and it shows "Bytes read from device = 0". Could you please give me some clue to find the problem.
Thanks
Solved! Go to Solution.
- Labels:
-
USB Superspeed Peripherals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Based on counters UART_RECEIVE_DATA_EVT is set 4 times but it is get 2 times, when 64 bytes are sent and CY_FX_UARTLT_BUF_SIZE =16.
>> Please try to reduce the the thread sleep from both UartOutUSBAppThread_Entry and UartInUSBAppThread_Entry threads
CyU3PThreadSleep (1);
Each counter step increasing shows that 16bytes is received by uart. But I can receive the first 32 bytes. after that when I send packets, I get error 997, while the mentioned counter is increasing.
>> Please let me know if the counter of CyU3PDmaChannelCommitBuffer increases according to the number of bytes sent from UART. As you mentioned earlier, that get events are not equal to the set events. If the data is not committed to USB socket using CyU3PDmaChannelCommitBuffer or if the data is not available to USB and if USB request is sent from Control center, timeout can happen which results to Error 997 on the control center
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The error code -7 is associated to LIBUSB_ERROR_TIMEOUT which is returned when the data is not received before the timeout expires.
Please let me know if the data from UART is sent in response to the data sent to UART from USB. If yes, please check if the data is sent to UART successfully as well as received by FX3 from UART.
You can also try to increase the timeout value if the data is received by FX3 from UART
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Tx and Rx paths are independent. As I mentioned, everything works well with CC. I don't change HW and FW, I only switch to cyusb_linux instead of CC.
I had increased the timeout value but no difference.
I have another problem, if I send data from Teraterm and I set transmit delay = 0 msec/char (teraterm/setup/serialport) and I send a file to fx3, I only got one byte. one rx event happens. (evType == CY_U3P_UART_EVENT_RX_DATA). But if I put transmit delay > 0 , I got all bytes that I sent. I am using register mode uart. baud rate=57600.
I can see this issue in cyfxuartlpregmode example, however based on my hardware I had to modified this example a bit but generally the same. I am using CY_U3P_IO_MATRIX_LPP_DEFAULT. When I write data manually in teraterm is it fine(as there is delay between Characters). but if I sent that data in a file with zero delay.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Tx and Rx paths are independent. As I mentioned, everything works well with CC. I don't change HW and FW, I only switch to cyusb_linux instead of CC.
>> I understand. But as the data is not received by the USB host when doing an IN transfer, we need to check if the data is committed to USB socket. Also, please capture and share the USB trace.
I have another problem, if I send data from Teraterm and I set transmit delay = 0 msec/char (teraterm/setup/serialport) and I send a file to fx3, I only got one byte
>> Please check if any of the API fails. Or you can probe the UART lines to check is the data. Also, please share the firmware for us to reproduce the issue. Is this problem OS dependent?
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
About the second question. I am sending data from Teraterm and receive it in CC.
At first I tried in getting data in EP, but for debugging and test now in attached FW I am trying to get in with a vendor command.
I put CY_FX_UARTLT_BUF_SIZE = 1, if I sent data manually I can see I get data (I put 4 counters in different part and they can be read by 0x14 vendor commands) but if I sent the for example 32 bytes in a file I only get 2 bytes.
I set CY_FX_UARTLT_BUF_SIZE = 8, in this situation I got 16 byte when I sent a file with 64 bytes(transmit delay =0). However if I sent a file with 16 bytes, wait and again send a file with 16 bytes, I can receive bytes. or if I send data manually I can get bytes.
I set CY_FX_UARTLT_BUF_SIZE = 16, in this situation I got 32 byte when I sent a file.
I set CY_FX_UARTLT_BUF_SIZE = 32, after send a file with 64 bytes when I am trying to read from vendor, I lost USB connection.
Actually my final goal is sending data stream from uart and read in the EP, but in debugging I reach to this point. Now In attached FW, EP has been ignored. I attached hex files as well.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have another problem, if I send data from Teraterm and I set transmit delay = 0 msec/char (teraterm/setup/serialport) and I send a file to fx3, I only got one byte
>> It seems that reading 1 byte at a time is causing the delay. Please try to read 32 bytes at once and change CY_FX_UARTLT_BUF_SIZE accordingly.
Also, while copying the buffer using CyU3PMemCopy the last parameter should be according to no of bytes received. In the firmware, I could see only 8 bytes were copied.
In addition to this while sending the data over control endpoint, please confirm if the number of bytes received and sent over USB are same
For example if 32 bytes is to be received from UART (without any delay)
//CY_U3P_UART_EVENT_RX_DATA
count = CyU3PUartReceiveBytes (&rxData, 32, &status);
if(UartDataCount == 1) {...}
// CY_U3P_UART_EVENT_RX_DATA
// UART_RECEIVE_DATA_EVT event
CyU3PMemCopy ((uint8_t*)UartInDataBuffer_r, (uint8_t*)UartInDataBuffer, 32);
UARTIn_ready = CyFalse;
UartDataCount = 0;
//vendor command
CyU3PMemCopy (glEp0Buffer, (uint8_t*)UartInDataBuffer_r, 32);
status = CyU3PUsbSendEP0Data(32, glEp0Buffer);
I have tested the firmware at my end and i am able to receive the bytes sent using .hex file.
If you cannot change the second parameter of CyU3PUartReceiveBytes to 32 bytes, you can try using the flow control by setting the following field of UART configuration
uartConfig.flowCtrl = CyTrue;
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rashi,
Thanks for your reply and help.
I did that changes, I put CY_FX_UARTLT_BUF_SIZE =16, when I send files with less than 32 bytes, I got bytes(based on counters which are read from vendor command), but if I send a file with 64 bytes, it stuck.
(when I put CY_FX_UARTLT_BUF_SIZE =32 and I read from ep, I lost USB connection so I tested with 16)
Beside that I added the DMA buffer to read data in bulk EP 0x82, but even if I could get data from UART, I only can read 32 bytes from EP and after that I got error 997.
I attached the modified FW.
Thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I got bytes(based on counters which are read from vendor command), but if I send a file with 64 bytes, it stuck.
>> Can you please let me know how many times UART_RECEIVE_DATA_EVT is set when 64 bytes are sent and CY_FX_UARTLT_BUF_SIZE =16. Also, as we are using CyU3PEventGet/set, you can remove the UARTIn_ready implementation. As both receiving data from UART and sending data to USB are independent, UARTIn_ready should not block receiving data when CyFxUartUSBApplnCallback is triggered.
Beside that I added the DMA buffer to read data in bulk EP 0x82, but even if I could get data from UART, I only can read 32 bytes from EP and after that I got error 997.
>> Please let me know how much data is received by FX3 over UART. If the data is not committed to USB socket, and USB IN request is sent to the device the USB request will fail with error 997 (i.e. timeout error)
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I removed UARTIn_ready.
Based on counters UART_RECEIVE_DATA_EVT is set 4 times but it is get 2 times, when 64 bytes are sent and CY_FX_UARTLT_BUF_SIZE =16.
For 128 bytes, UART_RECEIVE_DATA_EVT is set 8 times but it is get 2 times,
For Ep data, I can see that counter related to a successful CyU3PDmaChannelCommitBuffer increases, when I send data. Each counter step increasing shows that 16bytes is received by uart. But I can receive the first 32 bytes. after that when I send packets, I get error 997, while the mentioned counter is increasing.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Based on counters UART_RECEIVE_DATA_EVT is set 4 times but it is get 2 times, when 64 bytes are sent and CY_FX_UARTLT_BUF_SIZE =16.
>> Please try to reduce the the thread sleep from both UartOutUSBAppThread_Entry and UartInUSBAppThread_Entry threads
CyU3PThreadSleep (1);
Each counter step increasing shows that 16bytes is received by uart. But I can receive the first 32 bytes. after that when I send packets, I get error 997, while the mentioned counter is increasing.
>> Please let me know if the counter of CyU3PDmaChannelCommitBuffer increases according to the number of bytes sent from UART. As you mentioned earlier, that get events are not equal to the set events. If the data is not committed to USB socket using CyU3PDmaChannelCommitBuffer or if the data is not available to USB and if USB request is sent from Control center, timeout can happen which results to Error 997 on the control center
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks, it works with your comments.
since in the middle of the thread, with my new questions, my main question got sidetracked, I will open a new thread for my Linux problem.
Thanks for your help