最近在调试OV7670,7725,9650,9655,这些摄像头,发现一个共同问题,就是开窗函数不好用,我用的默认寄存器配置一点问题没有。
输出像素为640*480,但是想调整窗口就不对了。
我调用函数如下:
OV7670_config_window(0,0,639,479);
OV7670_config_window(0,0,640,480);
两种方式都不对。
void OV7670_config_window(unsigned int startx,unsigned int starty,unsigned int width, unsigned int height)
{
unsigned int endx;
unsigned int endy;// "v*2"必须
unsigned char temp_reg1, temp_reg2;
unsigned char state,temp;
endx=(startx+width*2);
endy=(starty+height*2);// "v*2"必须
state = ovrdreg(0x03, &temp_reg1 );
temp_reg1 &= 0xf0;
state = ovrdreg(0x32, &temp_reg2 );
temp_reg2 &= 0xc0;
// Horizontal
temp = temp_reg2|((endx&0x7)<<3)|(startx&0x7);
state = sccb_senddata(0x32, temp );
temp = (startx&0x7F8)>>3;
state = sccb_senddata(0x17, temp );
temp = (endx&0x7F8)>>3;
state = sccb_senddata(0x18, temp );
// Vertical
temp = temp_reg1|((endy&0x3)<<2)|(starty&0x3);
state = sccb_senddata(0x03, temp );
temp = starty>>2;
state = sccb_senddata(0x19, temp );
temp = endy>>2;
state = sccb_senddata(0x1A, temp );
}
但是我的寄存器配置无论是RGB565输出还是RAW8 输出都没问题。
窗口函数在初始化寄存器后调用,都有问题,不调用窗口函数是ok的,这样做的目的是为了验证窗口函数如何配置不同分辨率输出。
以下是我的初始化寄存器,是很ok的,此寄存器是针对ov7670的。
code unsigned char OV7670_RGB [200][2]=
{
{0x40, 0xe0}, //普通控制14
{0x12, 0x04}, //复位,VGA,RGB565 (00:YUV,04:RGB)(8x全局复位)
{0x40, 0xd0},
{0x3a, 0x00},
{0x3d, 0xc8},
{0x1e, 0x01},
{0x6b, 0x00},
{0x32, 0xb6}, //HREF控制
{0x17, 0x13}, //HSTART
{0x18, 0x01}, //HSTOP
{0x19, 0x02}, //VSTART
{0x1a, 0x7a}, //VSTOP,0x7a,
{0x03, 0x0a}, //VREF,0x0a,
{0x0c, 0x00}, //COM3 10 //default setting //10
{0x3e, 0x00}, //COM14 //default setting
{0x70, 0x00}, //SCALING_XSC
{0x71, 0x00}, //SCALING_YSC
{0x72, 0x11}, //SCALING_DCWCTR //default setting
{0x73, 0x00}, //SCALING_PC //default setting
{0xa2, 0x02}, //SCALING_PCLK_DELAY //default setting
{0x11, 0x81}, //{0x11, 0x81}, //CLKRC,2分频
{0x7a, 0x20}, //SLOP
{0x7b, 0x1c}, //GAM1
{0x7c, 0x28}, //GAM2 //20
{0x7d, 0x3c}, //GAM3
{0x7e, 0x55}, //GAM4
{0x7f, 0x68}, //GAM5
{0x80, 0x76}, //GAM6
{0x81, 0x80}, //GAM7
{0x82, 0x88}, //GAM8
{0x83, 0x8f}, //GAM9
{0x84, 0x96}, //GAM10
{0x85, 0xa3}, //GAM11
{0x86, 0xaf}, //GAM12 // 30
{0x87, 0xc4}, //GAM13
{0x88, 0xd7}, //GAM14
{0x89, 0xe8}, //GAM15
{0x13, 0xe0}, //COM8
{0x00, 0x00}, //AGC
{0x10, 0x00}, //AECH 00 ???
{0x0d, 0x00}, //COM4//default setting
{0x14, 0x28}, //0x38, limit the max gain 越大 曝光越厉害
{0xa5, 0x05}, //BD50MAX
{0xab, 0x07}, //BD60MAX //40
{0x24, 0x75}, //AEW
{0x25, 0x63}, //AEB
{0x26, 0xA5}, //VPT
{0x9f, 0x78}, //HAECC1 ff ???
{0xa0, 0x68}, //HAECC2 ff
{0xa1, 0x03}, //RSVD,0x0b,
{0xa6, 0xdf}, //HAECC3,0xd8, ff
{0xa7, 0xdf}, //HAECC4,0xd8, ff
{0xa8, 0xf0}, //HAECC5 ff
{0xa9, 0x90}, //HAECC6 ff //50
{0xaa, 0x94}, //HAECC7
{0x13, 0xef}, //COM8 e5
{0x0e, 0x61}, //COM5
{0x0f, 0x4b}, //COM6
{0x16, 0x02}, //RSVD
//{0x1e, 0x07}, //MVFP,0x07,07
{0x21, 0x02}, //ADCCTR1
{0x22, 0x91}, //ADCCTR2
{0x23, 0x00}, //ADCCTR2
{0x29, 0x07}, //RSVD //60
{0x33, 0x0b}, //CHLF
{0x35, 0x0b}, //RSVD
{0x37, 0x1d}, //ADC
{0x38, 0x71}, //ACOM
{0x39, 0x2a}, //OFON
{0x3c, 0x78}, //COM12 65
{0x4d, 0x40}, //RSVD
{0x4e, 0x20}, //RSVD
{0x69, 0x00}, //GFIX 0x5d
//{0x6b, 0x00}, //DBLV,PLL=inX4 0x60 //70
{0x74, 0x19}, //REG4
{0x8d, 0x4f}, //RSVD
{0x8e, 0x00}, //RSVD
{0x8f, 0x00}, //RSVD
{0x90, 0x00}, //RSVD
{0x91, 0x00}, //RSVD
{0x92, 0x00}, //DW_LNL,0x19,//0x66
{0x96, 0x00}, //RSVD
{0x9a, 0x80}, //RSVD
{0xb0, 0x84}, //RSVD //80
{0xb1, 0x0c}, //ABLC1
{0xb2, 0x0e}, //RSVD
{0xb3, 0x82}, //THL_DLT
{0xb8, 0x0a}, //RSVD //84
{0x43, 0x14}, //AWBC1
{0x44, 0xf0}, //AWBC2
{0x45, 0x34}, //AWBC3
{0x46, 0x58}, //AWBC4
{0x47, 0x28}, //AWBC5
{0x48, 0x3a}, //AWBC6
{0x59, 0x88}, //RSVD
{0x5a, 0x88}, //RSVD
{0x5b, 0x44}, //RSVD
{0x5c, 0x67}, //RSVD
{0x5d, 0x49}, //RSVD
{0x5e, 0x0e}, //RSVD
{0x64, 0x04}, //LCC3
{0x65, 0x20}, //LCC4
{0x66, 0x05}, //LCC5
{0x94, 0x04}, //LCC6
{0x95, 0x08}, //LCC7 100
{0x6c, 0x0a}, //AWBCTR3
{0x6d, 0x55}, //AWBCTR2
{0x6e, 0x11}, //AWBCTR1
{0x6f, 0x9f}, //AWBCTR0,0x9e for advance AWB
{0x6a, 0x40}, //GGAIN
{0x01, 0x40}, //BLUE
{0x02, 0x40}, //RED
{0x13, 0xe7}, //COM8
{0x15, 0x00}, //COM10
//{0x2d, 0x00},
/* Color Matrix */
{0x4f, 0x80}, //MTX1
{0x50, 0x80}, //MTX2
{0x51, 0x00}, //MTX3
{0x52, 0x22}, //MTX4
{0x53, 0x5e}, //MTX5
{0x54, 0x80}, //MTX6
// {0x55, 0x00}, //亮度//default setting
// {0x56, 0x52}, //对比度
{0x58, 0x9e}, //MTXS
{0x41, 0x08}, //COM16
{0x3f, 0x00}, //边缘增强调整 0x05
{0x75, 0x05}, //REG75
{0x76, 0xe1}, //REG76
{0x4c, 0x00}, //噪声抑制强度
{0x77, 0x01}, //REG77 0x0a
// {0x3d, 0xc2}, //0xc0,
{0x4b, 0x09}, //REG4B
{0xc9, 0x60}, //SATCTR
{0x41, 0x38}, //COM16
{0x56, 0x40}, //0x40, change according to Jim's request
{0x34, 0x11}, //ARBLM
{0x3b, 0x02}, //COM11,0x00,//0x02,
{0xa4, 0x89}, //0x88,
{0x96, 0x00}, //RSVD
{0x97, 0x30}, //RSVD
{0x98, 0x20}, //RSVD 135
{0x99, 0x30}, //RSVD
{0x9a, 0x84}, //RSVD
{0x9b, 0x29}, //RSVD
{0x9c, 0x03}, //RSVD
{0x9d, 0x4c}, //BD50ST
{0x9e, 0x3f}, //BD60ST
{0x78, 0x04}, //RSVD
{0x79, 0x01}, //RSVD
{0xc8, 0xf0}, //RSVD
{0x79, 0x0f}, //RSVD
{0xc8, 0x00}, //RSVD
{0x79, 0x10}, //RSVD
{0xc8, 0x7e}, //RSVD
{0x79, 0x0a}, //RSVD
{0xc8, 0x80}, //RSVD
{0x79, 0x0b}, //RSVD
{0xc8, 0x01}, //RSVD
{0x79, 0x0c}, //RSVD
{0xc8, 0x0f}, //RSVD
{0x79, 0x0d}, //RSVD
{0xc8, 0x20}, //RSVD
{0x79, 0x09}, //RSVD
{0xc8, 0x80}, //RSVD
{0x79, 0x02}, //RSVD
{0xc8, 0xc0}, //RSVD
{0x79, 0x03}, //RSVD
{0xc8, 0x40}, //RSVD
{0x79, 0x05}, //RSVD
{0xc8, 0x30}, //RSVD
{0x79, 0x26}, //RSVD
{0x09, 0x03}, //COM2
{0x3b, 0x42}, //COM11,x82,//0xc0,//0xc2, //night mode 167
};
|