TKWTKW 发表于 2010-12-12 21:11:33

关于OV7660窗口像素设置函数的疑问!!

//(140,16,640,480) is good for VGA
//(272,16,320,240) is good for QVGA
/* config_OV7660_window */
void OV7660_config_window(uint startx,uint starty,uint width, uint height)
{
        uint endx=(startx+width);
        uint endy=(starty+height*2);// "v*2"必须
        uchar temp_reg1, temp_reg2;
        uchar state,temp;
       
        state = rdOV7660Reg(0x03, &temp_reg1 );
        temp_reg1 &= 0xC0;
        state = rdOV7660Reg(0x32, &temp_reg2 );
        temp_reg2 &= 0xC0;
       
        // Horizontal
        temp = temp_reg2|((endx&0x7)<<3)|(startx&0x7);
        state = wrOV7660Reg(0x32, temp );
        temp = (startx&0x7F8)>>3;
        state = wrOV7660Reg(0x17, temp );
        temp = (endx&0x7F8)>>3;
        state = wrOV7660Reg(0x18, temp );
       
        // Vertical
        temp = temp_reg1|((endy&0x7)<<3)|(starty&0x7);
        state = wrOV7660Reg(0x03, temp );
        temp = (starty&0x7F8)>>3;
        state = wrOV7660Reg(0x19, temp );
        temp = (endy&0x7F8)>>3;
        state = wrOV7660Reg(0x1A, temp );
}
这个函数中:uint endx=(startx+width);
       uint endy=(starty+height*2);// "v*2"必须

这两个语句是什么意思??
startx和starty的值有什么特殊要求吗??
为什么starty 要加两次 height??
如果要设置成QQVGA的格式该怎么设置???

TKWTKW 发表于 2010-12-13 12:42:41

没人知道吗???

TKWTKW 发表于 2010-12-13 13:16:51

还有我查看了一下。。。DATSHEET。。。感觉应该
// Vertical
temp = temp_reg1|((endy&0x7)<<3)|(starty&0x7);
state = wrOV7660Reg(0x03, temp );
temp = (starty&0x7F8)>>3;
state = wrOV7660Reg(0x19, temp );
temp = (endy&0x7F8)>>3;
state = wrOV7660Reg(0x1A, temp );
设置有问题!!!帧方向应该是低两位和高八位。。。所以因该是这样设置:

temp = temp_reg1|((endy&0x3)<<2)|(starty&0x3);//取垂直像素开始和结束的低两位并且结束低两位取完后左移两位
        state = wrOV7660Reg(0x03, temp );//设置垂直像素开始和结束低两位,开始低两位在1~0,结束低三位在3~2
        temp = (starty&0x7FC)>>2;
        state = wrOV7660Reg(0x19, temp );//设置垂直像素开始高八位
        temp = (endy&0x7FC)>>2;
        state = wrOV7660Reg(0x1A, temp ); //设置垂直像素结束高八位

TKWTKW 发表于 2010-12-13 13:18:01

这是经过我注释的:


/(140,16,640,480) is good for VGA
//(272,16,320,240) is good for QVGA
/* config_OV7660_window */
void OV7660_config_window(uint startx,uint starty,uint width, uint height)
{
        uint endx=(startx+width);
        uint endy=(starty+height*2);// "v*2"必须
        uchar temp_reg1, temp_reg2;
        uchar state,temp;
       
        state = rdOV7660Reg(0x03, &temp_reg1 );
        temp_reg1 &= 0xC0;
        state = rdOV7660Reg(0x32, &temp_reg2 );
        temp_reg2 &= 0xC0;
       
        // Horizontal -水平
        temp = temp_reg2|((endx&0x7)<<3)|(startx&0x7);//取水平像素开始和结束的低三位并且结束低三位取完后左移三位
        state = wrOV7660Reg(0x32, temp );//设置水平像素开始和结束低三位,开始低三位在2~0,结束低三位在5~3
        temp = (startx&0x7F8)>>3;
        state = wrOV7660Reg(0x17, temp );//设置水平像素开始高八位
        temp = (endx&0x7F8)>>3;
        state = wrOV7660Reg(0x18, temp );   //设置水平像素结束高八位
       
        // Vertical-垂直
        /*temp = temp_reg1|((endy&0x7)<<3)|(starty&0x7);
        state = wrOV7660Reg(0x03, temp );
        temp = (starty&0x7F8)>>3;
        state = wrOV7660Reg(0x19, temp );
        temp = (endy&0x7F8)>>3;
        state = wrOV7660Reg(0x1A, temp );*/
      temp = temp_reg1|((endy&0x3)<<2)|(starty&0x3);//取垂直像素开始和结束的低两位并且结束低两位取完后左移两位
        state = wrOV7660Reg(0x03, temp );//设置垂直像素开始和结束低两位,开始低两位在1~0,结束低三位在3~2
        temp = (starty&0x7FC)>>2;
        state = wrOV7660Reg(0x19, temp );//设置垂直像素开始高八位
        temp = (endy&0x7FC)>>2;
        state = wrOV7660Reg(0x1A, temp ); //设置垂直像素结束高八位
}

chengying 发表于 2016-6-27 18:13:15

TKWTKW 发表于 2010-12-13 13:18
这是经过我注释的:




你测试可以吗?
页: [1]
查看完整版本: 关于OV7660窗口像素设置函数的疑问!!