BULK OUT transfer failed with Error Code:997
>> this error occurs when the DMA buffers are not empty for the USB socket to fill the data. Which also means the data is not read as fast as the data is written. This is because the GPIF is configured for serial mode
Please let me know the number of DMA buffer and the DMA buffer size used in the application. You can try increasing the count of DMA buffers (please note that the total no of DMA buffers should not be more than then allocated memory for DMA buffers (refer to cyfxtx.c)).
The firmware worked well before I change it to 2-threads. I could send 4 MB data by that in serial before this changes. Only my problem was losing data every 16KB so i decide to use from 2-thread GPIF II.
now I think maybe, it is stopped somewhere(state machine or multiple DMA doesn't work well or i should add something in code)
I tested different numbers of DMA buffers,for example, if the number of DMA buffer and the DMA buffer size:
#define CY_FX_DMA_BUF_SIZE (16384)
#define CY_FX_DMA_BUF_COUNT (4)
then for 2-threads, I can send (16 *4) *2 KB text file. when i change the code to a 3 threads, it increase to (16 *4) * 3 KB.
I attached my firmware.
UsbtoGpif_OUT.zip 1.3 MB
The firmware seems fine.
Please let me know how much amount of data do you send through control center. Are you directly transferring some file (Transfer file out) or just random data through (transfer data out).
When do you get the error. Does the error occur after few successful transfers or the very first transfer fails?
I actually want to transfer directly through "Transfer file out". however I tested "transfer data out". this problem is for both of them.
For the attached firmware, It doesn't depend on how many files I send, as soon as size of send files get to 144KB, I got this error.
so depend on size of file, It can occur on the first transfer or after a few successful transfers.
For example I can send :
1 file with 144KB size or
9 files 16KB or
3 files with: 64KB , 64 KB, 16 KB
after this amount, this error occurs.
As I mentioned before, the firmware worked well before I change it to 2-threads. I could send 4 MB data by that in serial before this changes. but now it stops after 144 KB.
I attached my test files(16KB, 64KB).
I appreciate it if let me know that is there any example for multiple thread in GPIF for sending continuous data from USB to GPIF to help me on my project , just like "reversing" the configuration in AN75779? In AN75779, data goes from GPIF to USB, but I have problem from USB to GPIF.
Apologies for late reply.
I reproduced the issue at my end.
In the firmware you shared, i found that the configuration for serial out is 0x00001F83, /* CY_U3P_PIB_GPIF_SERIAL_OUT_CONFIG */
which is socket zero ( as mentioned in GPIF_SEROUT_THREAD_NUMBER_MASK (bit 3:2) is configured for data sink (from USB to GPIF).
As you are using two sockets (thread) in you firmware, this field should be 0. So that the socket is chosen internally (as per the thread)
So the configuration should be 0x00001F81, /* CY_U3P_PIB_GPIF_SERIAL_OUT_CONFIG */
I have tested this at my end. Refer to the results
PS: I have changed the DMA buffer size and endpoint size to 1024 (for testing purpose)
Many many thanks for your big help.
It was the exactly that I was looking for.