0v7670窗口显示异常

2019-12-27 19:04发布

在320X240的液晶上显示qvga,一切正常。打算让摄像头显示在窗口280X200,怎么都是错位。
void OV_HW(unsigned int  hstart, unsigned int hstop, unsigned int vstart, unsigned int vstop)
{
    uint8_t v;
    OV7670_WriteReg(0x17, (hstart >> 3) & 0xff); //HSTART
    OV7670_WriteReg(0x18, (hstop >> 3) & 0xff); //HSTOP
    OV7670_ReadReg(0x32,&v);
    v = (v & 0xc0) | ((hstop & 0x7) << 3) | (hstart & 0x7);
    OV7670_WriteReg(0x32, v); //HREF

    OV7670_WriteReg(0x19, (vstart >> 2) & 0xff); //VSTART 开始高8位
    OV7670_WriteReg(0x1a, (vstop >> 2) & 0xff); //VSTOP        结束高8位
     OV7670_ReadReg(0x03,&v );
    v = (v & 0xf0) | ((vstop & 0x3) << 2) | (vstart & 0x3);
   OV7670_WriteReg(0x03, v); //VREF
    OV7670_WriteReg(0x11, 0x00);
}