OV7670 camera to LCD, 25 fps at 320x240 RGB565

cspwcspw
Posts: 18
Joined: Mon Apr 16, 2018 5:08 pm

OV7670 camera to LCD, 25 fps at 320x240 RGB565

Postby cspwcspw » Sat Sep 08, 2018 6:55 pm

Hi

I got my OV7670 camera delivering 25 frames per second through the ESP32 to an 320x240 pixel LCD screen.
Each pixel is RGB565 format (2 bytes).

The code and some docs are at https://github.com/cspwcspw/ESP32_CamToLCD

Peter

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: OV7670 camera to LCD, 25 fps at 320x240 RGB565

Postby ESP_igrr » Sun Sep 09, 2018 2:54 pm

Very nice write-up, thanks for sharing!

cspwcspw
Posts: 18
Joined: Mon Apr 16, 2018 5:08 pm

Re: OV7670 camera to LCD, 25 fps at 320x240 RGB565

Postby cspwcspw » Fri Sep 21, 2018 4:43 pm

On the OV7670 camera, I think I've partially understood the HSTART and HSTOP registers. In the I2S camera code, (and indeed on a few different solutions working with the camera), the authors typically say

Code: Select all

frameControl(196, 52, 8, 488); //no clue why horizontal needs such strange values

So here is a clue: the horizontal timing is such that a VGA scan line takes 784 PCLKs (640 + 144 PCLK times between lines). So HSTOP must be 640 bigger than HSTART, but modulus 784. So for any HSTART value, we can compute HSTOP as (HSTART + 640) % 784. This has worked nicely for me. My experiments also indicate that HSTOP points to the pixel beyond the last one. (HSTART + 639) % 768 just slews my images.
Camera_specs.png
Camera_specs.png (36.56 KiB) Viewed 9772 times
Now why does HSTART begin at such a weird value? I'm still puzzed. I suspect it counts PCLKs relative to HSYNC (which is not broken out onto a pin, or easily observable), but I cannot find any obvious synchonization point or timing that explains HSTART.

Any ideas or extra insights, please let me know. If you can tell me how to get HSTART, I thinnk I can tell you how to get HSTOP.

Peter

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Re: OV7670 camera to LCD, 25 fps at 320x240 RGB565

Postby Deouss » Tue Nov 20, 2018 6:15 pm

I am looking at some camera code on github and just seeing that there is something undocumented in I2S api like two lines from the idf library file (i2s.c)
I2S[i2s_num]->conf2.lcd_en = 0;
I2S[i2s_num]->conf2.camera_en = 0;

It seems like there is a dedicated functionality for camera and lcd in I2S api and it is not documented or maybe I just cannot find it.
The interesting thing is how those data bits from camera are transformed parallely to DMA as byte datas by I2S.
I guess it is dedicated behavior by selecting camera_en = true and also what exacly gpio_matrix_() does to the selected pins and what is the signal index value
I am just trying to understand how I2S works in such case

Who is online

Users browsing this forum: No registered users and 28 guests