FX3 override mode data lost

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.
louyuminghamn
Level 1
Level 1
10 sign-ins 5 replies posted 5 sign-ins

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

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

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

Regards,
Rashi

View solution in original post

0 Likes
11 Replies
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

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.

Regards,
Rashi
0 Likes
lock attach
Attachments are accessible only for community members.

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.

louyuminghamn_1-1638412537653.png

 

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:

louyuminghamn_0-1638412053560.png

You can find more details in the attachment.

Please kindly give me some advice.

Thanks a lot,

Yuming

0 Likes

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

Regards,
Rashi
0 Likes

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

0 Likes

Hello,

Please let me know if the control goes to the else condition when ZLP is committed by GPIF SM.

Regards,
Rashi
0 Likes
lock attach
Attachments are accessible only for community members.

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. )

louyuminghamn_0-1638494386811.png

louyuminghamn_1-1638494431128.png

I attached my firmware here.

Thanks,

Yuming

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

After going through the uvc.c, I found that the status of CyU3PDmaMultiChannelGetBuffer is not checked before adding either the leader or trailer. Please try using the attached uvc.c in your firmware and let me know if there are any improvements

Regards,
Rashi
0 Likes
lock attach
Attachments are accessible only for community members.

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?

louyuminghamn_0-1638510959273.png

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.

louyuminghamn_0-1638513425694.png

 

 

Thank you much,

Yuming

0 Likes
lock attach
Attachments are accessible only for community members.

Hello Yuming,

Please try the attached AN75779 firmware which add 52 bytes of leader and 32 bytes of trailer for every frame.

We checked this using the Wireshark trace. Please let me know if this works.

Regards,
Rashi
0 Likes

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.

louyuminghamn_0-1638848558698.png

louyuminghamn_1-1638848756947.png

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

0 Likes
lock attach
Attachments are accessible only for community members.

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

Regards,
Rashi
0 Likes