Register configuration for the realization of camera drive 0V7725
August 23, 2021
Register configuration for the realization of camera drive 0V7725
SCCB timing
The picture below is the overall framework implemented by OV7725, which is a bit ugly. FPGA describes the SCCB timing and completes the configuration of the OV7725. After the configuration is completed, the OV7725 sensor outputs PCLK and href, vsync and cmos_data signals. After the format conversion unit, the data after format conversion is sent to the SDRAM unit, and finally VGA/LCD/host computer display is realized.
The SCCB interface mainly implements the configuration of various registers inside the sensor, such as AGC, AWB, gama, color saturation, etc.,The configuration of the register is explained below. The reference manual is shown in the figure below. The register configuration also needs to be used in conjunction with the register setting chapter in the OV7725 manual.
In the last chapter of the manual, reference settings are given, but the output format is YCbCr format, other settings need to contact FAE.
As shown in the figure below, the first 8 bits of data written in the register, such as 0x3d represents the address of the register, and the last 8 bits 0x03 represent the value set by the register.According to the final content of the manual, the description of the relevant registers can be found in the 0V7725 datasheet (OV7725 datasheet).
For example, 0x3d, the function represented in the data sheet (OV7725 datasheet) is the control of the DC offset.As shown in the figure below, other registers can be found by analogy. Note that the register address or the name of the register can be set during the setting, such as 0x3d, 0x03, or com12, 0x03.
In the OV7725 configuration manual, the conversion method between YCbCr and RGB24 format is described. As shown in the figure below, because FPGA is not good at handling floating-point numbers, it needs to be converted into fixed-point number processing.
In the OV7725 configuration manual, a detailed description of the OV7725 format output is described, divided into ISP and no ISP situations. This module can build a format output unit inside the FPGA. This aspect will be explained later.
For the register setting, according to the reference setting in the OV7725 application manual, there are several important parts that must be set, as shown below:
1. ID setting
For manufacturers, each sensor has a unique ID address.
Manufacturer’s unique ID address.
2. Reset all registers
After power-on, reset all the registers inside the OV first. Register 12 not only has a reset function, but also controls the OV video output format, which will be mentioned below, see item 10.
3.DC bias in analog processing
4.Setting of rows and fields
The 17-bit row start control of the register, 18 is the downstream pixel size in VGA mode. 19 is the start of field control, and 1A is the field pixel size in VGA mode.
5.Invert the vertical sync signal
In order to be consistent with the VGA timing, the timing of VSYNC is reversed. For the timing diagram of one frame, refer to the previous blog.
write_SCCB (Ox15, Ox02); for this setting, pclk is defined as valid on the rising edge, href is positioned as valid at high level, and vsync is reversed.
6.The starting position and size control of the image
7.Size control of line and field output data
8.Internal clock control
Register 0d is to set the frequency multiplier of the internal PLL, select 4 multiplier, AEC automatic exposure control selects one-half window.
Register 11 is the setting of the internal clock. After multiplying by PLL4, the calculated result should be equal to the XCLK clock.
9.High Insertion of Virtual Pixels
The default values given in the configuration manual above are actually useless.
10.OV video format output configuratio
Register 12, function multiplexing, write_SCCB (Ox12, Ox06); the output format is RGB565 format.So this register is very important and determines the format of OV output.
11.RGB format YUV format sequence and test color bar control
write_SCCB (Ox0c, Ox10); Among them, register 0c controls the sequence of RGB and YUV format, and also controls the enable of the test color bar inside the OV. The default value is used here, and the color bar is not enabled.
12.DSP control parameters
Among them, the 0x42 register controls the backlight compensation blue control amount, as shown in the figure below, select the manual reference value.
Among them, 0x4d is the control of the repair gain, and 0x42 sets the B component of the backlight compensation color.
Register 0x63 is the control of AWB automatic white balance control word 0. Select the default value in the manual. 0xf0;
Registers 0x64~67 are controlled by DSP as 1~4, 0x64 is set as the default value 0xff in the configuration register; 0x65 is the default value of the manual, and the configuration manual is 0x20, and the default value 0x00 is selected, which does not affect the imaging effect.0x66 is the alternate format of UV. Select 0x00. 0x67 is the output format selection, here set 0x00/0x01, it is YUV or RGB output.
13.AWB, AEC, AGC parameter control adjustment
0x13 controls whether AEC, AWB, AGC are enabled, set to 0xff; 0x0f controls the window to automatically adapt when the output format is converted. 0x14 set 0x11.0x22 set to 0x98, as a 50Hz bandwidth filter.In the OV7725 register configuration manual, 0x13, 0x22, and 0x23 are about the setting of the band-pass filter in the case of an AC frequency of 50 Hz and a frame frequency of 25.
14.Edge strengthening treatment
Both choose to configure the specified value.
15.Color reproduction matrix setting
16. Brightness, contrast, UV and SDE control
Choose the default value.
17.gama parameter settings
Among them, the registers 0x7e~0x8c are the settings of the gama curve, setting the default value of the configuration manual.
18.UV control
write_sccb{0xa7, 0x65};
write_sccb{0xa8, 0x65};
write_sccb{0xa9, 0x80};
write_sccb {0xaa, 0x80};
19.Automatically adjust the frame rate at night
The above is the setting of commonly used registers, most of which refer to the set value in the manual, and then we will realize the SCCB timing and realize the configuration of OV7725.