7 years ago.

STM32 with OV7670(FIFO) (SOLVED)

I have been trying to apply Fuyuno Sakura solution https://developer.mbed.org/users/mio/notebook/ov7670_with_al422b_qqvga_test/?c=27082 to my platform STM32F303 Nucleo without success. First I had some kind of success (in that I could get some image -although reddish and not clear) but only if I change the I2C freq to 400000 (Fuyuno uses 50000). I was surprised since I think 50000 is not a standard I2C freq.

Then I realized that I was using some pins that the Nucleo datasheet says are unconnected (C14 C15) and also some pins that they don't recommend (A13 A14) So I rewired that and now the normal I2C freq (100000) works (Fuyuno's 50000 does not) but the image now is very unstable and unrecognizable.

The OV7670 datasheet is not much of a help and I suspect that something involving speed settings is what is not working. In other words, the initialization of the camera. TheOv7670 with FIFO seems to get its clock from a oscilator (24MHz) and that goes to the AL422B FIFO. My Nucleo seems to run at 72MHz (different than the original Fuyuno LPC 1768 that I think runs at 96MHz)

Can someone help me with the initialization of this camera? Any recommendations on settings, or wiring that I should use? Any pointer will help me since I am stuck right now

1 Answer

7 years ago.

Study this source code which should be similar for your target:

https://github.com/una1veritas/ARMWork/tree/master/stm32f3x_OV7670

Thanks. I opened the link. I also studied two other sources (one for the magazine Transistor mentioned by Fuyuno, and another from the vendor-the link above is a modification of that one) In the three of them, they *don't use the I2C libraries, but implement them*. I also read another homepage and the author also mentioned that STM32 I2C doesn't seem to work with the OV7670 SCCB. I am wondering if that is my problem...

posted by Cristian Fuentes 20 Apr 2017

Update

Recommend to focus first on getting the SCCB routines to be solid. It should be very possible to review how Fuyuno supports the SCCB interface and you can apply to your project. Perform testing of reading assorted registers from the OV7670 using your new routines and confirm they are solid. They move to writing and then reading the registers and confirm they are solid. Only then move to configure the required registers and then map to a local LCD display or whatever you wish to do with the captured information. They are many websites that are chatting on how to work with the OV7670 and STM or other processors. It may be also practical to review the low cost boards from Aliexpress if only to gain some knowledge on how to make the interfaces work and read out correct data. There are many variables to your project so best if you proceed and attack each systematically.

posted by Sanjiv Bhatia 20 Apr 2017

Thank you for your advice. I would like to update. I have now been able to get an image in my LCD. The image has the correct color. Problems: The image is disfigured by intense random colors (I mean you can see the object but the colors are sometimes wrong) I don't know if this is a problem of the camera or a problem of the LCD display. In any case I measured the times. Camera capture time takes 47-48 ms (which is wonderful but weird because I am not using the fast PortIn that Sakura recommended yet) and the FIFO read of data takes 217 ms. LCD displaying is included in the camera capture time (and has no bad influence- I measured). I would think of reducing FIFO read time but I read the camera needs time to recover between captures. I would appreciate any comment on my situation Thanks

posted by Cristian Fuentes 21 Apr 2017

UPDATE: I have finally solved this problem(except the issue that I posted in other question that my programs don't work automatically and I have to reprogram them twice for them to work-Weird! help me there!) The problem was in the speed of transmission. I believed erroneously- as I posted in the previous comment that the BusIn-PortIn choice had influence in the camera capture time. It does not. This has influence in the FIFO read of data. My problem was that the FIFO read data (217ms) was too slow compared with the camera capture time(47ms). I reprogrammed the data as PortIn and now I have camera capture time(66ms) and FIFO read data (32ms) which permits me to have a very clear image of what the camera is taking.

posted by Cristian Fuentes 26 Apr 2017