Strange Behavior of MT9V034 Monochrome UVC with false DMA buffer count

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.
mata_4758791
Level 2
Level 2
First like received 10 sign-ins 5 sign-ins

Dear, I got a very strange behavior, the dmabuffer count is alway incorrect.

First, for testing purpose, I wired the Most significant 8 bits i.e. D[15:8] to 0x80 and connect the Least significant 8 bits i.e. D[7:0] to sensor output. Now,
(1) If I use the 16bits format, the 8-bit monochrome data from the sensor will be sent as a 'Y' value and 0x80 will be sent instead of 'U' or 'V' value.
(2) If I use the 8bits format, I just got the Y value.

Please refer to the attached project for my code.

--------> Test I (8 bits format)

by setting width and height in cyfxuvcdscr9v034.c to the following parameter

#define UVC_WIDTH (unsigned int)376 //for testing
#define UVC_HEIGHT (unsigned int)480

I got the following picture,

MT9v034_take_YUV_mono_as_YUV2.png

It is clear that the camera has taken these 752x480 bytes as the format of 376x480 YUV2 format. Up till now we can say the the data streaming is of no problem, at least the hardware connections are correct!

----------> Test 2

Now I make the following change to my project,

tab1_interface_definition.png

(***change I) change the above setting to

#define UVC_WIDTH (unsigned int)752 #define UVC_HEIGHT (unsigned int)480

(***change II) according to https://community.cypress.com/thread/11106?start=0, I made the following change to the project,

\1. Configure GPIF for 16-bit bus width by selecting 16 Bit in the Data bus width field of Interface Definition tab of GPIF II Designer. 

\2. set  LD_DATA_COUNT and LD_ADDR_COUNT to 8183, since the GPIF bus width is changed to 16 bits. 

\3. Rebuild the GPIF project after making the above mentioned changes. 

USART debug log


[2020-11-19 22:36:46.438]# RECV ASCII>
UsbEventCB: Detected SS USB Connection
USBSetupCB:In SET_FTR 0::1
USBSetupCB:In SET_FTR 0::1
USBSetupCB:In SET_FTR 0::1
USBSetupCB:In SET_FTR 0::1

[2020-11-19 22:36:47.330]# RECV ASCII>
UVC: Completed 0 frames and 0 buffers

[2020-11-19 22:36:48.302]# RECV ASCII>
UVC: Completed 0 frames and 0 buffers

[2020-11-19 22:36:49.280]# RECV ASCII>
UVC: Completed 0 frames and 0 buffers

[2020-11-19 22:36:50.269]# RECV ASCII>
UVC: Completed 0 frames and 0 buffers
Application Started
UVC: Completed 0 frames and 0 buffers, current count = 0

[2020-11-19 22:36:51.241]# RECV ASCII>
UVC: Completed 52 frames and 31 buffers, current count = 1728

[2020-11-19 22:36:52.217]# RECV ASCII>
UVC: Completed 105 frames and 20 buffers, current count = 1728

[2020-11-19 22:36:53.195]# RECV ASCII>
UVC: Completed 158 frames and 9 buffers, current count = 1728

Now I can get just a black screen; and I don't understand why this count is 1728, it should be 16384-16=16368bytes.

(***change III)

Not sure what is problem, and I made some additional change for testing according to https://community.cypress.com/thread/34847?q=commit%20buffer%20prob

(1) Set the CY_FX_UVC_STREAM_BUF_SIZE = 36K and CY_FX_UVC_STREAM_BUF_COUNT = 3.

(2) set ADDR_COUNT_LIMITER and DATA_COUNT_LIMITER to (((36K-16) /2) -1 ) = 18423

(3) Then modify No. of bytes device can rx in single payload in probe control structure to 0x9000 as follows:

"0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload = 36 KB */"

(4) add some addition debug info in the app loop, the debug results are given as follows,

[2020-11-20 09:56:07.338]# RECV ASCII>
UsbEventCB: Detected SS USB Connection
USBSetupCB:In SET_FTR 0::1
USBSetupCB:In SET_FTR 0::1

[2020-11-20 09:56:08.224]# RECV ASCII>
Current status = 0
UVC: Completed 0 frames and 0 buffers, current count = 0

[2020-11-20 09:56:09.186]# RECV ASCII>
Current status = 0
UVC: Completed 0 frames and 0 buffers, current count = 0

[2020-11-20 09:56:10.162]# RECV ASCII>
Current status = 0
UVC: Completed 0 frames and 0 buffers, current count = 0

[2020-11-20 09:56:11.139]# RECV ASCII>
Current status = 0
UVC: Completed 0 frames and 0 buffers, current count = 0

[2020-11-20 09:56:12.133]# RECV ASCII>
Current status = 0
UVC: Completed 0 frames and 0 buffers, current count = 0

[2020-11-20 09:56:12.833]# RECV ASCII>
Current status = 0
Application Started
UVC: Completed 0 frames and 0 buffers, current count = 0

[2020-11-20 09:56:13.796]# RECV ASCII>
Current status = 7
UVC: Completed 52 frames and 15 buffers, current count = 21808

[2020-11-20 09:56:14.788]# RECV ASCII>
Current status = 6
UVC: Completed 105 frames and 10 buffers, current count = 21808

[2020-11-20 09:56:15.750]# RECV ASCII>
Current status = 7
UVC: Completed 158 frames and 5 buffers, current count = 21808

[2020-11-20 09:56:16.740]# RECV ASCII>
Current status = 6
UVC: Completed 211 frames and 0 buffers, current count = 21808

[2020-11-20 09:56:17.703]# RECV ASCII>
Current status = 7
UVC: Completed 263 frames and 17 buffers, current count = 21808

[2020-11-20 09:56:18.695]# RECV ASCII>
Current status = 6
UVC: Completed 316 frames and 12 buffers, current count = 21808

[2020-11-20 09:56:19.657]# RECV ASCII>
Current status = 6
UVC: Completed 369 frames and 8 buffers, current count = 21808

[2020-11-20 09:56:20.678]# RECV ASCII>
Current status = 7
UVC: Completed 422 frames and 3 buffers, current count = 21808
Clear feature request detected...
Current status = 6
Application Stopped
UVC: Completed 0 frames and 0 buffers, current count = 21808

[2020-11-20 09:56:21.650]# RECV ASCII>
Current status = 6
UVC: Completed 0 frames and 0 buffers, current count = 21808

[2020-11-20 09:56:22.627]# RECV ASCII>
Current status = 6
UVC: Completed 0 frames and 0 buffers, current count = 21808

I can see that the DMA buffer is committing data, but the count value is 21808, it should be 36*1024-16 = 36848.

I'm perplexed by this strange behavior, where am I doing wrong?

0 Likes
1 Solution
mata_4758791
Level 2
Level 2
First like received 10 sign-ins 5 sign-ins

Dear,

This topic can be closed now, I got the reason at glProbeCtrl, set the Max video frame correct and the problem solved.

For Test 1,  the image can be displayed OK, it doesn't matter the max video frame rate is correct or NOT, I don't know why, but it is the case.

regards.

matthew

View solution in original post

0 Likes
2 Replies
mata_4758791
Level 2
Level 2
First like received 10 sign-ins 5 sign-ins

Dear,

This topic can be closed now, I got the reason at glProbeCtrl, set the Max video frame correct and the problem solved.

For Test 1,  the image can be displayed OK, it doesn't matter the max video frame rate is correct or NOT, I don't know why, but it is the case.

regards.

matthew

0 Likes
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi Matthew,

In the attached project, when tried with 8-bit format, max frame size is 0x96000 - corresponding to 640*480*2 which is more than 376*480*2.

But it will be less than 752*480*2.

So, as long as dwMaxVideoFrameSize is more than the frame size being streamed, I think it should be fine.

Regards,

Hemanth

Hemanth
0 Likes