OV7670 Software Application Note
OV7670 Software Application Note
Table of Contents
OV7670 Software Application Note.................................................................................................... 1
1. Select Output format.................................................................................................................... 3
1.1 Backend with full ISP........................................................................................................... 3
1.2 Backend with YCbCr ISP..................................................................................................... 4
1.3 Backend without ISP.............................................................................................................4
1.4 Equations to Convert from One Format to Another............................................................. 4
2. Select Output Resolution?........................................................................................................... 5
2.1 Backend with ISP..................................................................................................................5
2.2 Backend without ISP.............................................................................................................5
3. Adjust frame rate......................................................................................................................... 5
3.1 Frame Rate Adjustment for 24Mhz input clock....................................................................5
30 fps, PCLK = 24Mhz.......................................................................................................... 5
15 fps, PCLK = 12Mhz.......................................................................................................... 5
25fps, PCLK = 24Mhz........................................................................................................... 5
14.3fps, PCLK = 12Mhz........................................................................................................ 6
3.2 Frame Rate Adjustment for 26 Mhz input clock...................................................................6
30 fps, PCLK = 26Mhz.......................................................................................................... 6
15 fps, PCLK = 13Mhz.......................................................................................................... 6
25fps, PCLK = 26Mhz........................................................................................................... 6
14.3fps, PCLK = 13Mhz........................................................................................................ 7
3.3 Frame rate adjustment for 13 Mhz input clock..................................................................... 7
30 fps, PCLK = 26Mhz.......................................................................................................... 7
15 fps, PCLK = 13Mhz.......................................................................................................... 7
25fps, PCLK = 26Mhz........................................................................................................... 7
14.3fps, PCLK = 13Mhz........................................................................................................ 7
4. Night Mode.................................................................................................................................. 8
4.1 Night Mode with Fixed Frame Rate..................................................................................... 8
For 24Mhz/26Mhz Clock Input..............................................................................................8
For 13Mhz Clock Input.......................................................................................................... 8
4.2 Night Mode with Auto Frame Rate.......................................................................................8
For 24Mhz/26Mhz Clock Input..............................................................................................8
For 13Mhz Clock Input.......................................................................................................... 9
5. Remove Light Band................................................................................................................... 10
5.1 Light Band...........................................................................................................................10
5.2 Remove Light band............................................................................................................. 10
5.3 Select Banding Filter by Region Information..................................................................... 10
Banding Filter Setting for 24Mhz Input Clock.................................................................... 11
Banding Filter Setting for 13Mhz/26Mhz Input Clock........................................................ 11
5.4 Select Banding Filter by Automatic Light Frequency Detection........................................12
Banding Filter Setting for 24Mhz Input Clock.................................................................... 12
Banding Filter Setting for 13Mhz/26Mhz Input Clock........................................................ 13
5.5 When Light Band can not be Removed.............................................................................. 14
6. White Balance............................................................................................................................14
6.1 Simple White Balance.........................................................................................................14
6.2 Advanced White Balance....................................................................................................14
Camera Interface
YCbCr
RGB
Bayer raw RGB
Processed raw RGB
LCD Driver
X
Memory Interface
RGB
JPEG
The data format at LCD driver are always RGB. For example, RGB444, RGB565, RGB555,
RGB888 etc. The data format and memory interface are always JPEG. The JPEG data is
compressed from YCbCr data. So Both RGB and YCbCr data are needed inside the backend chip.
The X block is different for different backend chips.
I2c_salve_Address = 0x42;
write_i2c(0x11, 0x80);
write_i2c(0x6b, 0x0a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x00);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
15 fps, PCLK = 12Mhz
i2c_salve_Address = 0x42;
write_i2c(0x11, 0x00);
write_i2c(0x6b, 0x0a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x00);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
25fps, PCLK = 24Mhz
i2c_salve_Address = 0x42;
write_i2c(0x11, 0x80);
write_i2c(0x6b, 0x0a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x66);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
14.3fps, PCLK = 12Mhz
i2c_salve_Address = 0x42;
write_i2c(0x11, 0x00);
write_i2c(0x6b, 0x0a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x1a);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
I2c_salve_Address = 0x42;
write_i2c(0x11, 0x80);
write_i2c(0x6b, 0x0a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x2b);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
15 fps, PCLK = 13Mhz
i2c_salve_Address = 0x42;
write_i2c(0x11, 0x00);
write_i2c(0x6b, 0x0a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x2b);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
25fps, PCLK = 26Mhz
i2c_salve_Address = 0x42;
write_i2c(0x11, 0x80);
write_i2c(0x6b, 0x0a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x99);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
14.3fps, PCLK = 13Mhz
i2c_salve_Address = 0x42;
write_i2c(0x11, 0x00);
write_i2c(0x6b, 0x0a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x46);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
I2c_salve_Address = 0x42;
write_i2c(0x11, 0x00);
write_i2c(0x6b, 0x4a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x2b);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
15 fps, PCLK = 13Mhz
i2c_salve_Address = 0x42;
write_i2c(0x11, 0x01);
write_i2c(0x6b, 0x4a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x2b);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
25fps, PCLK = 26Mhz
i2c_salve_Address = 0x42;
write_i2c(0x11, 0x00);
write_i2c(0x6b, 0x4a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x99);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
14.3fps, PCLK = 13Mhz
i2c_salve_Address = 0x42;
write_i2c(0x11, 0x01);
write_i2c(0x6b, 0x4a);
write_i2c(0x2a, 0x00);
write_i2c(0x2b, 0x00);
write_i2c(0x92, 0x46);
write_i2c(0x93, 0x00);
write_i2c(0x3b, 0x0a);
4. Night Mode
There are 2 types of settings for night mode. One type is set to fixed low frame rate, for example
3.75fps. The other type is set to auto frame rate, for example from 30fps to 3.75fps. When
environment is bright, the frame rate is increased to 30fps. When environment is dark, the frame
rate is decreased to 3.65fps.
i2c_salve_Address = 0x42;
write_i2c(0x3b, 0xca);
write_i2c(0x11, 0x00);
25fps ~ 3.125fps night mode for 50Hz light environment
i2c_salve_Address = 0x42;
write_i2c(0x3b, 0xea);
write_i2c(0x11, 0x80);
14.3fps ~ 3.6fps night mode for 50Hz light environment
i2c_salve_Address = 0x42;
write_i2c(0x3b, 0xca);
write_i2c(0x11, 0x00);
For 13Mhz Clock Input
AC
Light
Exposure
Not n/100, has band
= n/100, no band
The strength of office light is not even. It changes with AC frequency. For example, if the AC
frequency is 50Hz, the light changes strength at 100hz.
6. White Balance
OV7670 support simple white balance and advanced balance.
Settings
Contact with OmniVision local FAE.
8. BLC
The function of Black Level Calibration (BLC) is to product accurate color in the dark area of
picture. There is automatic BLC function built-in OV7670. It should always be turned on.
9. Video Mode
Video mode need high frame rate, usually fixed 15fps. There is no night mode for video mode.
write_i2c(0x51, 0x00);
write_i2c(0x52, 0x28);
write_i2c(0x53, 0x71);
write_i2c(0x54, 0x99);
write_i2c(0x58, 0x9e);
Saturation 0
i2c_salve_Address = 0x42;
write_i2c(0x4f, 0x80);
write_i2c(0x50, 0x80);
write_i2c(0x51, 0x00);
write_i2c(0x52, 0x22);
write_i2c(0x53, 0x5e);
write_i2c(0x54, 0x80);
write_i2c(0x58, 0x9e);
Saturation -1
i2c_salve_Address = 0x42;
write_i2c(0x4f, 0x66);
write_i2c(0x50, 0x66);
write_i2c(0x51, 0x00);
write_i2c(0x52, 0x1b);
write_i2c(0x53, 0x4b);
write_i2c(0x54, 0x66);
write_i2c(0x58, 0x9e);
Saturation - 2
i2c_salve_Address = 0x42;
write_i2c(0x4f, 0x40);
write_i2c(0x50, 0x40);
write_i2c(0x51, 0x00);
write_i2c(0x52, 0x11);
write_i2c(0x53, 0x2f);
write_i2c(0x54, 0x40);
write_i2c(0x58, 0x9e);
11.3 Brightness
The brightness of OV7670 could be adjusted. Higher brightness will make the picture more
bright. The side effect of higher brightness is the picture looks frogy.
Brightness +2
i2c_salve_Address = 0x42;
write_i2c(0x55, 0x30);
Brightness +1
i2c_salve_Address = 0x42;
write_i2c(0x55, 0x18);
Brightness 0
i2c_salve_Address = 0x42;
write_i2c(0x55, 0x00);
Brightness -1
i2c_salve_Address = 0x42;
write_i2c(0x55, 0x98);
Brightness -2
i2c_salve_Address = 0x42;
write_i2c(0x55, 0xb0);
11.4 Contrast
The contrast of OV7670 could be adjusted. Higher contrast will make the picture sharp. But the
side effect is loosing dynamic range.
Contrast +2
i2c_salve_Address = 0x42;
write_i2c(0x56, 0x60);
Contrast +1
i2c_salve_Address = 0x42;
write_i2c(0x56, 0x50);
Contrast 0
i2c_salve_Address = 0x42;
write_i2c(0x56, 0x40);
Contrast -1
i2c_salve_Address = 0x42;
write_i2c(0x56, 0x38);
Contrast -2
i2c_salve_Address = 0x42;
write_i2c(0x56, 0x30);
Greenish
i2c_salve_Address = 0x42;
write_i2c(0x3a, 0x14);
write_i2c(0x67, 0x40);
write_i2c(0x68, 0x40);
Redish
i2c_salve_Address = 0x42;
write_i2c(0x3a, 0x14);
write_i2c(0x67, 0xc0);
write_i2c(0x68, 0x80);
B&W
i2c_salve_Address = 0x42;
write_i2c(0x3a, 0x14);
write_i2c(0x67, 0xc80);
write_i2c(0x68, 0x80);
Negative
i2c_salve_Address = 0x42;
write_i2c(0x3a, 0x24);
write_i2c(0x67, 0x80);
write_i2c(0x68, 0x80);
B&W negative
i2c_salve_Address = 0x42;
write_i2c(0x3a, 0x34);
write_i2c(0x67, 0x80);
write_i2c(0x68, 0x80);
Normal
i2c_salve_Address = 0x42;
write_i2c(0x3a, 0x04);
write_i2c(0x67, 0xc0);
write_i2c(0x68, 0x80);
12.3 Resolution
The resolution of camera module depends on lens design, focus adjustment and sensor resolution
as well. The focus adjustment is very important for camera module assembly.
For OV7670 the focus distance is about 40~50cm. The depth of field is about from 20~25cm to
infinite. If checking resolution of camera module, the resolution chart should be placed 40~50 cm
away.
42 7c 1e
42 7d 35
42 7e 5a
42 7f 69
42 80 76
42 81 80
42 82 88
42 83 8f
42 84 96
42 85 a3
42 86 af
42 87 c4
42 88 d7
42 89 e8
;
42 13 e0
42 01 50
42 02 68
42 00 00
42 10 00
42 0d 40
42 14 18
42 a5 07
42 ab 08
42 24 95
42 25 33
42 26 e3
42 9f 78
42 a0 68
42 a1 03
42 a6 d8
42 a7 d8
42 a8 f0
42 a9 90
42 aa 94
42 13 e5
;
42 0e 61
42 0f 4b
42 16 02
42 1e 07
42 21 02
42 22 91
42 29 07
42 33 0b
42 35 0b
42 37 1d
42 38 71
42 39 2a
42 3c 78
42 4d 40
42 4e 20
42 69 00
42 6b 0a
42 74 10
42 8d 4f
42 8e 00
42 8f 00
42 90 00
42 91 00
42 92 66
42 96 00
42 9a 80
42 b0 84
42 b1 0c
42 b2 0e
42 b3 82
42 b8 0a
;
42 43 14
42 44 f0
42 45 34
42 46 58
42 47 28
42 48 3a
42 59 88
42 5a 88
42 5b 44
42 5c 67
42 5d 49
42 5e 0e
42 64 04
42 65 20
42 66 05
42 94 04
42 95 08
42 6c 0a
42 6d 55
42 6e 11
42 6f 9f ;9e for advance AWB
42 6a 40
42 01 40
42 02 40
42 13 e7
;
42 4f 80
42 50 80
42 51 00
42 52 22
42 53 5e
42 54 80
42 58 9e
;
42 41 08
42 3f 00
42 75 03
42 76 e1
42 4c 00
42 77 00
42 3d c2
42 4b 09
42 c9 60
42 41 38
42 56 40
;
42 34 11
42 3b 0a
42 a4 88
42 96 00
42 97 30
42 98 20
42 99 30
42 9a 84
42 9b 29
42 9c 03
42 9d 98
42 9e 3f
42 78 04
;
42 79 01
42 c8 f0
42 79 0f
42 c8 00
42 79 10
42 c8 7e
42 79 0a
42 c8 80
42 79 0b
42 c8 01
42 79 0c
42 c8 0f
42 79 0d
42 c8 20
42 79 09
42 c8 80
42 79 02
42 c8 c0
42 79 03
42 c8 40
42 79 05
42 c8 30
42 79 26
42 2d 00
42 2e 00
42 35 0b
42 37 1c
42 38 71
42 3c 78
42 3d 08
42 41 3a
42 4d 40
42 4e 20
42 69 55
42 6b 4a
42 74 19
42 76 61
42 8d 4f
42 8e 00
42 8f 00
42 90 00
42 91 00
42 96 00
42 9a 80
42 b0 8c
42 b1 0c
42 b2 0e
42 b3 82
42 b8 0a
;
42 43 14
42 44 f0
42 45 34
42 46 58
42 47 28
42 48 3a
42 59 88
42 5a 88
42 5b 44
42 5c 67
42 5d 49
42 5e 0e
42 6c 0a
42 6d 55
42 6e 11
42 6f 9f
42 6a 40
42 01 40
42 02 40
42 13 e7
;
42 34 11
42 92 66
42 3b 0a
42 a4 88
42 96 00
42 97 30
42 98 20
42 99 20
42 9a 84
42 9b 29
42 9c 03
42 9d 4c
42 9e 3f
42 78 04
;
42 79 01
42 c8 f0
42 79 0f
42 c8 20
42 79 10
42 c8 7e
42 79 0b
42 c8 01
42 79 0c
42 c8 07
42 79 0d
42 c8 20
42 79 09
42 c8 80
42 79 02
42 c8 c0
42 79 03
42 c8 40
42 79 05
42 c8 30
42 79 26
RGB565
contact OmniVision local FAE