cancel
Showing results for 
Search instead for 
Did you mean: 

OV2640 on STM32F446ZE using DCMI DMA and UART with NUCLEO board

lanotted
Associate II

Hello,

I’ve been working for a few weeks on a personal project concerning cameras with OV2640 sensors. I am using a MCU F446ZE mounted on NUCLEO board. As you can see from the product tab, to use this card for cameras, implies the use of various links. After reading the ST application note about these cameras, I set to work to create a firmware that could, through the DCMI port, save my data (in my case i want a JPEG) in memory and then use the UART port to view data related to my photo. I’ve seen that many have posted these kinds of questions, but no one has post either a solution or a tutorial. Reading the OMINIVISION manuals, I tried to follow all the steps they provide for setting up registers. The problem is that, when I try to write some registers, on terminal I get the error that I could not write. At this point I turned to the web, where I found some interesting solutions regarding the code. Of course my starting code has changed a lot, but I was never able to visualize anything on the UART. I ask you for help in solving my problem. At the moment therefore I do not have any kind of result other than to write some registers with the use of I2C. I enclose the images of the project and the code of the main and the camera part. There is a bit of disorder, but do not pay attention

9 REPLIES 9
TDK
Guru

> HAL_UART_Transmit(&huart3, framebuf,RESOLUTION_WIDTH * RESOLUTION_HEIGHT / 2, 3000);

If you're just sending raw data over UART, you aren't going to see anything useful in the terminal. You would need to save that info and process it back into an image.

Your problem is quite complex in that it involves quite a few components. Break it down into steps. Ensure the link to the camera works, then ensure you can transmit over UART correctly, then ensure you can postprocess that data to reconstruct the image. If one of those steps gives trouble, post a question with detailed information about what you're trying and what went wrong.

It's easier to answer specific technical questions than it is to answer generic "I tried X but it didn't work, what is wrong?"

If you feel a post has answered your question, please click "Accept as Solution".
First of all, thank you for your reply. Looking at the various documents I mentioned, no one talks about processing the data sent from this specific room. We talk about JPEG and looking at the examples provided by st, there is no processing. I checked the links 1000 times and everything is ok.  What I’d like is a technical opinion on what I’ve done, to see what’s wrong. The UART also use it to view errors as well as information regarding the image.

lanotted
Associate II
update. 
As suggested I am proceeding with small steps. I realized a function that could write the registers of the OV2640, through the I2C. initially I could not write the logs and I analyzed the bus signals (SDA and SCL). I found that at 100 Khz the signals were meaningless, so I lowered the frequency to 10 Khz. Now it is ok.
I also realize a check on every register to make sure I wrote what I wanted. I find that some registers are not written. can anyone give me some advice on this? could it depend on the camera clock (12 Mhz)?
  •  

TDK
Guru

> I found that at 100 Khz the signals were meaningless, so I lowered the frequency to 10 Khz. Now it is ok.

What does meaningless mean here? I2C should be able to operate at 100kHz, that is the standard speed. Datasheet says it should work up to 400kHz.

https://www.uctronics.com/download/OV2640_DS.pdf

> I find that some registers are not written.

If communication works in general, and only a few specific registers seem to not work, then probably the answer lies with what those registers are exactly. Perhaps you are misinterpreting how they should be behaving.

If you feel a post has answered your question, please click "Accept as Solution".
I know, I read the datasheet and all the documentation of 'ov2640 (application note software and hardware, document about sccb). I think 100khz is the recommended speed normally. in my case I have wires that can easily introduce capacitive effects and electromagnetic disturbances, which at 100khz created a distortion of the signal. I found myself having a sine wave and not a square wave.
 
about the registers there are some that are reserved on the datasheet, but if you take a look around but especially on the documentation of the ominivision, they are written, to set the various modes.

lanotted
Associate II
Update.
Finally after careful analysis I came to the conclusion. I can write all the registers of the OV2640 and I was also able to obtain synchronization and data signals, typical of JPEG data , that is square waves. Now my question to you is:
I have to manage the buffer frame that is enhanced thanks to the Hal_dcmi_start_dma in snapshot mode. How do I see it via UART? How do I know when it’s actually ready?

lanotted
Associate II
Hello everyone, as I’ve had a lot of problems with the omnivision cmos sensors, and finally managed to write the logs correctly, I share my experience with you. The ov2640, ov7740 etc. generate the ack in contrast to what is written online. The solution lies in the I2C management that needs an external pull-up network (Vdd 3V3 and R 2.7 Kohm) and you can simply use the instructions I2c_mem_write and I2c_mem_read. I hope someone needs it. Does anyone know how to determine the size of the JPEG that generates the OV2640, in order to capture the images correctly? Unfortunately if I don’t define the size, the dcmi never generates the end frame interrupt

Hi @lanotted ,

If it's available, can you share the code of OV2640?

Best Regards.

Posts from 3 years ago, user detail may have been lost in forum migration or email addresses changed.

Perhaps look at github for MVCAM or similar projects using this and similar cameras on STM32 platforms. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..