- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, There,
We are using CYUSB3KIT-003 (the P/N of the chip is CYUSB3014) to design a camera. We need to send a leader and a trailer as single transfers before and after each frame. So I used the override mode to add the leader and trailer. I modified the AN75779 to test the override mode.
I add the leader in the GPIF CB function and the trailer in DMA CB function. I also added 2 states in the GPIF state machine: SOF0 and SOF1 to get the SOF signal from the camera (it’s a pulse 5ms before FRAME VALID signal ) to interrupt the CPU. In these 2 interrupts, I add the 52 bytes Leader of the frame. The resolution of my design is 1920*1200 Mono8 (1 byte per pixel) and the frame rate is 30 FPS. I set the buffer burst size to be 18K (18*1024). So there should be 125 transfer of 18K blocks, one leader and one trailer for each frame. I used AMCap to start the transfer though I know there will be no video in the viewer. I only need to see the USB traces.
But the trace I got is not as my expectation. The data blocks will sometimes be 124, and sometimes there will be one data block between the leader and trailer. The app will stop running after several seconds with an EP_UNDERRUN error. You can see the details in the attachment.
Please kindly give me some help.
Thank you much in advance.
Yuming
Solved! Go to Solution.
- Tags:
- fx3
- override mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Apologies for late reply.
For 1920*1200 Mono8 video resolution, please try using DMA buffer size of 18432 (18KB) / 18384 bytes and let me know if the issue is seen.
Please note that the Rx payload size in the probe control structure should be greater or equal to the DMA buffer size.
To avoid the problem, please confirm that the DMA Buffer size is set such that the partial buffer size is not multiple of 1024 bytes.
For 1920*1200*1 = 2304000 bytes
DMA buffer size = 18432 (18KB)
Full buffer =125
Partial Buffer size = 0 (no partial buffer)
RX payload size (probe control structure) = 18432 (18KB)
I have checked adding leader and trailer to default AN75779 firmware (without UVC header) and I could see that header and trailer are sent properly. Please check the attached snippet
Please let me know if that works
Regards,
Rashi
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please refer to this thread Solved: Re: USB3 Vision DMA on Leader packet on FX3 - Infineon Developer Community with similar application.
If your application is similar to the one mentioned in the thread you can refer to the GPIF state machine so that there is no need of using DMA channel in override mode. Please check the GPIF state machine shared in the thread and the explanation for the same.
If you want to use the DMA channel in override mode for your application, you can refer to this KBA DMA Channel in Override Mode in FX3/CX3 - KBA22909... - Infineon Developer Community
Kindly let me know if any queries on it. Please note that the LD_ADDR_COUNT and LD_DATA_COUNT need to be modified based on the DMA buffer size and the GPIF bus width.
I set the buffer burst size to be 18K (18*1024). So there should be 125 transfer of 18K blocks
>> The frame size is 1920*1200*1= 2304000 bytes which is exact multiple of 18K (18432 bytes). To use UVC state machine in AN75779, frame size should not be an exact multiple of DMA buffer size. If it is an exact multiple, then there will be no partial buffer to indicate the frame end. Hence, we suggest to use a DMA buffer size accordingly.
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Rashi:
Thank you for your reply. I tried your state machine, but only the Leader side (STATE 18 and 21) can work. I cannot capture the commit for the Trailer (STATE 19 and 22). A ZLP will show on USB traces where there should be a trailer. I attached the USB traces here.
I changed the buffer burst length to 36K and the UVC can work properly. The only change I made for the leader and trailer is inside the "CyFxUvcApplnDmaCallback" function as showed below:
You can find more details in the attachment.
Please kindly give me some advice.
Thanks a lot,
Yuming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Yuming,
From the state machine I noticed that the transition equation between FRAME_END_SCK0 and STATE 22 / FRAME_END_SCK1 and STATE 19 should be !FW_TRG&DMA_RDY_TH1 and !FW_TRG&DMA_RDY_TH0 respectively
Please do these changes and let me know if the the control goes to the else condition when ZLP is committed by GPIF SM.
Also, we would not recommend to use CyU3PDebugPrint (blocking call) inside the DMA callback. Please use global variables or events to check the error condition of the APIs called inside DMA callback
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Rashi:
Thank you for your quick reply. Actually, I tried both way (swap !FW_TRG&DMA_RDY_TH1 and !FW_TRG&DMA_RDY_TH0), the results are the same.
Yuming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please let me know if the control goes to the else condition when ZLP is committed by GPIF SM.
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Rashi:
I can capture the trailer now, but it's always with the last payload transfer (I need to send it as a single transfer).
My buffer burst size is 36K. So for a 1920*1200 frame, it should have 62 full buffer and one 18432 bytes buffer. When I checked the debug print, the CY_U3P_DMA_CB_PROD_EVENT is entered 65 times (62 full + 1*18432 byte + 1 leader +1 trailer). But the USB traces only shows 64 transfers. The Trailer is at the end of the last payload which made a 18464 byte transfer. (I have deleted the 12 bytes UVC header and footer. )
I attached my firmware here.
Thanks,
Yuming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Rashi:
I have tried this way (I double checked with your code just now also). The result are exactly the same.
My understanding is that the last CyU3PDmaMultiChannelGetBuffer function is to check whether there are any buffers come faster than the DMA callback function being called. Is that correct?
In my debug print, I saw CyU3PDmaMultiChannelGetBuffer has been called 65 times for each frame. And the last block has 18432 bytes. Which all seems correct. So my wild guess is that the CyU3PDmaSocketSetWrapUp function takes too long time, and wrap up the last 2 partially filled together. Could that be?
The other error in the USB traces is that the last full buffer comes 14 ms later which is already the time for the next frame. These problems will gone if I add the UVC header and footer and change the counter in the GPIF SM back to 9211(if there is no UVC header and foot, the counter is 9215). But my application cannot have UVC header and footer, so please kindly give me some advice.
Thank you much,
Yuming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Rash:
I checked your firmware with 32-bits input. The only change I made on your firmware is the LD_DATA/ADDR_COUNT (from 16367 to 4091). I can see the Leader and Trailer in single transfer. But the last 2 payload block length seems not correct.
Could you kindly do the following check on your side:
1. Double check the last 2 payload size to see whether they are correct.
2. In the GPIF SM, you set the data/addr count to be 16367 which still takes off the 16 bits offsets for UVC header/footer, although you set the header and footer to 0 in DMA config in the firmware. Could you set the count to be 16383 (16*1024-1) in GPIF and check if the Trailer is still a single transfer?
Thank you so much for your help.
Yuming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Apologies for late reply.
For 1920*1200 Mono8 video resolution, please try using DMA buffer size of 18432 (18KB) / 18384 bytes and let me know if the issue is seen.
Please note that the Rx payload size in the probe control structure should be greater or equal to the DMA buffer size.
To avoid the problem, please confirm that the DMA Buffer size is set such that the partial buffer size is not multiple of 1024 bytes.
For 1920*1200*1 = 2304000 bytes
DMA buffer size = 18432 (18KB)
Full buffer =125
Partial Buffer size = 0 (no partial buffer)
RX payload size (probe control structure) = 18432 (18KB)
I have checked adding leader and trailer to default AN75779 firmware (without UVC header) and I could see that header and trailer are sent properly. Please check the attached snippet
Please let me know if that works
Regards,
Rashi
Rashi