当前位置: 代码迷 >> 驱动开发 >> 调试OV5640的驱动,那个急可为什么会出现这样的镜头
  详细解决方案

调试OV5640的驱动,那个急可为什么会出现这样的镜头

热度:77   发布时间:2016-04-28 10:15:56.0
调试OV5640的驱动,那个急啊,可为什么会出现这样的画面?


[@blueskycoco] [@saqula]  [@zhengmeifu]  [@HuaiShuShuV]

代码如下:

void OV5640_init(void)
{
long delay_time;

//15fps VGA YUV output 
// 24MHz input clock, 24MHz PCLK
//software reset
sensor_write(0x3103, 0x11); // system clock from pad, bit[1]
sensor_write(0x3008, 0x82); // software reset, bit[7]
for(delay_time = 0; delay_time < 0x4FFFD; delay_time++)
asm("nop;");//复位需要延时5ms
sensor_write(0x3008, 0x42); // software power down, bit[6]
sensor_write(0x3103, 0x03); // system clock from PLL, bit[1]
sensor_write(0x3017, 0xff); // FREX, Vsync, HREF, PCLK, D[9:6] output enable
sensor_write(0x3018, 0xff); // D[5:0], GPIO[1:0] output enable
sensor_write(0x3034, 0x1a); // MIPI 10-bit
sensor_write(0x3037, 0x13); // PLL root divider, bit[4], PLL pre-divider, bit[3:0]
sensor_write(0x3108, 0x01); // PCLK root divider, bit[5:4], SCLK2x root divider, bit[3:2]
// SCLK root divider, bit[1:0]
sensor_write(0x3630, 0x36);
sensor_write(0x3631, 0x0e);
sensor_write(0x3632, 0xe2);
sensor_write(0x3633, 0x12);
sensor_write(0x3621, 0xe0);
sensor_write(0x3704, 0xa0);
sensor_write(0x3703, 0x5a);
sensor_write(0x3715, 0x78);
sensor_write(0x3717, 0x01);
sensor_write(0x370b, 0x60);
sensor_write(0x3705, 0x1a);
sensor_write(0x3905, 0x02);
sensor_write(0x3906, 0x10);
sensor_write(0x3901, 0x0a);
sensor_write(0x3731, 0x12);
sensor_write(0x3600, 0x08); // VCM control
sensor_write(0x3601, 0x33); // VCM control
sensor_write(0x302d, 0x60); // system control
sensor_write(0x3620, 0x52);
sensor_write(0x371b, 0x20);
sensor_write(0x471c, 0x50);
sensor_write(0x3a13, 0x43); // pre-gain = 1.047x
sensor_write(0x3a18, 0x00); // gain ceiling
sensor_write(0x3a19, 0xf8); // gain ceiling = 15.5x
sensor_write(0x3635, 0x13);
sensor_write(0x3636, 0x03);
sensor_write(0x3634, 0x40);

sensor_write(0x3622, 0x01);
// 50/60Hz detection     50/60Hz 灯光条纹过滤
sensor_write(0x3c01, 0x34); // Band auto, bit[7]
sensor_write(0x3c04, 0x28); // threshold low sum
sensor_write(0x3c05, 0x98); // threshold high sum
sensor_write(0x3c06, 0x00); // light meter 1 threshold[15:8]
sensor_write(0x3c07, 0x08); // light meter 1 threshold[7:0]
sensor_write(0x3c08, 0x00); // light meter 2 threshold[15:8]
sensor_write(0x3c09, 0x1c); // light meter 2 threshold[7:0]
sensor_write(0x3c0a, 0x9c); // sample number[15:8]
sensor_write(0x3c0b, 0x40); // sample number[7:0]
sensor_write(0x3810, 0x00); // Timing Hoffset[11:8]
sensor_write(0x3811, 0x10); // Timing Hoffset[7:0]
sensor_write(0x3812, 0x00); // Timing Voffset[10:8]
sensor_write(0x3708, 0x64);
sensor_write(0x4001, 0x02); // BLC start from line 2
sensor_write(0x4005, 0x1a); // BLC always update
sensor_write(0x3000, 0x00); // enable blocks
sensor_write(0x3004, 0xff); // enable clocks
sensor_write(0x300e, 0x58); // MIPI power down, DVP enable
sensor_write(0x302e, 0x00);
sensor_write(0x4300, 0x32); // YUV 422, UYVY
sensor_write(0x501f, 0x00); // YUV 422
sensor_write(0x440e, 0x00); // ISP YUV 422
sensor_write(0x5000, 0xa7); // Lenc on, raw gamma on, BPC on, WPC on, CIP on
// AEC target    自动曝光控制
sensor_write(0x3a0f, 0x30); // stable range in high
sensor_write(0x3a10, 0x28); // stable range in low
sensor_write(0x3a1b, 0x30); // stable range out high
sensor_write(0x3a1e, 0x26); // stable range out low
sensor_write(0x3a11, 0x60); // fast zone high
sensor_write(0x3a1f, 0x14); // fast zone low
// Lens correction for ?   镜头补偿
sensor_write(0x5800, 0x23);
sensor_write(0x5801, 0x14);
sensor_write(0x5802, 0x0f);
sensor_write(0x5803, 0x0f);
sensor_write(0x5804, 0x12);
sensor_write(0x5805, 0x26);
sensor_write(0x5806, 0x0c);
sensor_write(0x5807, 0x08);
sensor_write(0x5808, 0x05);
sensor_write(0x5809, 0x05);
sensor_write(0x580a, 0x08);

sensor_write(0x580b, 0x0d);
sensor_write(0x580c, 0x08);
sensor_write(0x580d, 0x03);
sensor_write(0x580e, 0x00);