

为什么是偏的呢?用的是rp2040+ov7670(无fifo)+st7789(320*240)
<code>
void set_ov7670reg_7(void)
{
//Frame Rate Adjustment for 24Mhz input clock
//wrOV7670Reg(0x12, 0x80); // 软件复位
wrOV7670Reg(0x11, 0x80); // 30fps PCLK=24MHz (软件应用手册上设置的是0x80,例程设置的是0x00)
wrOV7670Reg(0x6b, 0x0a); // PLL控制 (软件应用手册上设置的是0x0a,例程设置的是0x40,将PLL调高的话就会产生花屏)//0x0a
wrOV7670Reg(0x2a, 0x00);
wrOV7670Reg(0x2b, 0x00);
wrOV7670Reg(0x92, 0x00);
wrOV7670Reg(0x93, 0x00);
wrOV7670Reg(0x3b, 0x0a);
//Output format
wrOV7670Reg(0x3a, 0x04);
wrOV7670Reg(0x40, 0xd0);
wrOV7670Reg(0x12, 0x16); // QVGA(320*240)、RGB 14
//wrOV7670Reg(0x12, 0x00); // VGA(640*480)、RGB
//RGB555/565 option(must set COM7[2] = 1 and COM7[0] = 0)
//wrOV7670Reg(0x40, 0x10); // RGB565,effective only when RGB444[1] is low
// 0b11010000 11: Output range: [00] to [FF], 01: RGB 565, effective only when RGB444[1] is low
wrOV7670Reg(0x8c, 0x00);
//Special effects - 特效 (normal)
// 0x04
wrOV7670Reg(0x67, 0x80);
wrOV7670Reg(0x68, 0x80);
//Mirror/VFlip Enable - 水平镜像/竖直翻转使能
wrOV7670Reg(0x1e, 0x01); // 修改配置值将产生图像显示上下或左右颠倒 //0x37
//Banding Filter Setting for 24Mhz Input Clock - 条纹滤波器 (30fps for 60Hz light frequency)
wrOV7670Reg(0x13, 0xe7); // banding filer enable
wrOV7670Reg(0x9d, 0x98); // 50Hz banding filer
wrOV7670Reg(0x9e, 0x7f); // 60Hz banding filer
wrOV7670Reg(0xa5, 0x02); // 3 step for 50Hz
wrOV7670Reg(0xab, 0x03); // 4 step for 60Hz
wrOV7670Reg(0x3b, 0x02); // select 60Hz banding filer
wrOV7670Reg(0x01,0xff);
wrOV7670Reg(0x02,0xff);
wrOV7670Reg(0x09,0x03);
// // //Simple White Balance - 白平衡
wrOV7670Reg(0x13, 0x00); // AWB、AGC、AGC Enable and ...
wrOV7670Reg(0x6f, 0x9f); // simple AWB
// //AWBC - 自动白平衡控制(Automatic white balance control)
// // 注:用户手册里这些寄存器的值都是保留(Reserved),不用设置的呀?
// wrOV7670Reg(0x43, 0x14);
// wrOV7670Reg(0x44, 0xf0);
// wrOV7670Reg(0x45, 0x34);
// wrOV7670Reg(0x46, 0x58);
// wrOV7670Reg(0x47, 0x28);
// wrOV7670Reg(0x48, 0x3a);
// //AWB Control
// // 注:用户手册连寄存器都是保留,初始值都没提供
// wrOV7670Reg(0x59, 0x88);
// wrOV7670Reg(0x5a, 0x88);
// wrOV7670Reg(0x5b, 0x44);
// wrOV7670Reg(0x5c, 0x67);
// wrOV7670Reg(0x5d, 0x49);
// wrOV7670Reg(0x5e, 0x0e);
// //AWB Control
// wrOV7670Reg(0x6c, 0x0a);
// wrOV7670Reg(0x6d, 0x55);
// wrOV7670Reg(0x6e, 0x11);
// wrOV7670Reg(0x6f, 0x9f);
// //AGC/AEC - Automatic Gain Control自动增益补偿/Automatic exposure Control自动曝光控制
// //wrOV7670Reg(0x00, 0x00);
// //wrOV7670Reg(0x14, 0x20);
// //wrOV7670Reg(0x24, 0x75);
// //wrOV7670Reg(0x25, 0x63);
// //wrOV7670Reg(0x26, 0xA5);
// //AEC algorithm selection - AEC公式选择
wrOV7670Reg(0xaa, 0x94); // 基于平均值的AEC算法Average-based AEC algorithm/基于直方图的AEC算法Histogram-based AEC algorithm
//基于直方图的AGC/AEC的控制
// wrOV7670Reg(0x9f, 0x78);
// wrOV7670Reg(0xa0, 0x68);
// wrOV7670Reg(0xa6, 0xdf);
// wrOV7670Reg(0xa7, 0xdf);
// wrOV7670Reg(0xa8, 0xf0);
// wrOV7670Reg(0xa9, 0x90);
// //Fix Gain Control - 固定增益控制
wrOV7670Reg(0x69, 0x5d); // Fix gain for Gr channel/for Gb channel/for R channel/for B channel
// //Color saturation 颜色饱和度 + 0
// wrOV7670Reg(0x4f, 0x80);
// wrOV7670Reg(0x50, 0x80);
// wrOV7670Reg(0x51, 0x00);
// wrOV7670Reg(0x52, 0x22);
// wrOV7670Reg(0x53, 0x5e);
// wrOV7670Reg(0x54, 0x80);
// wrOV7670Reg(0x58, 0x9e);
//Brightness - 亮度 + 0
wrOV7670Reg(0x55, 0x00);
// //Contrast - 对比度 + 0
wrOV7670Reg(0x56, 0x40);
// //Gamma Curve - 伽马曲线
// wrOV7670Reg(0x7a, 0x20);
// wrOV7670Reg(0x7b, 0x1c);
// wrOV7670Reg(0x7c, 0x28);
// wrOV7670Reg(0x7d, 0x3c);
// wrOV7670Reg(0x7e, 0x55);
// wrOV7670Reg(0x7f, 0x68);
// wrOV7670Reg(0x80, 0x76);
// wrOV7670Reg(0x81, 0x80);
// wrOV7670Reg(0x82, 0x88);
// wrOV7670Reg(0x83, 0x8f);
// wrOV7670Reg(0x84, 0x96);
// wrOV7670Reg(0x85, 0xa3);
// wrOV7670Reg(0x86, 0xaf);
// wrOV7670Reg(0x87, 0xc4);
// wrOV7670Reg(0x88, 0xd7);
// wrOV7670Reg(0x89, 0xe8);
// //Matrix Coefficient - 色彩矩阵系数
// wrOV7670Reg(0x4f, 0x80);
// wrOV7670Reg(0x50, 0x80);
// wrOV7670Reg(0x51, 0x00);
// wrOV7670Reg(0x52, 0x22);
// wrOV7670Reg(0x53, 0x5e);
// wrOV7670Reg(0x54, 0x80);
//Lens Correction Option - 镜头补偿选项
// wrOV7670Reg(0x62, 0x00);
// wrOV7670Reg(0x63, 0x00);
// wrOV7670Reg(0x64, 0x04);
// wrOV7670Reg(0x65, 0x20);
// wrOV7670Reg(0x66, 0x05);
// wrOV7670Reg(0x94, 0x04); // effective only when LCC5[2] is high
// wrOV7670Reg(0x95, 0x08); // effective only when LCC5[2] is high
//注释这些配置的话,就倾斜显示,并显示多块,这到底是控制什么的?跟时序图有关?
wrOV7670Reg(0x17, 0x00); // 行频Horizontal Frame开始高八位(低三位在HREF[2:0])
wrOV7670Reg(0x18, 0x00); // 行频Horizontal Frame结束高八位(低三位在HREF[5:3])
wrOV7670Reg(0x19, 0x00); // 场频Vertical Frame开始高八位(低二位在VREF[1:0])
wrOV7670Reg(0x1a, 0x00); // 场频Vertical Frame结束高八位(低二位在VREF[3:2])
wrOV7670Reg(0x32, 0x00); // HREF
wrOV7670Reg(0x03, 0x00); // VREF
// //注释这个配置的话,就显示花屏了
wrOV7670Reg(0x15, 0x02); // 配置PCLK、HREF、VSYNC相关
// //Automatic black Level Compensation - 自动黑电平校正
wrOV7670Reg(0xb0, 0x84); // 调试时注释这项配置时,颜色显示不正常了,红色变绿色,绿色变红色,但用户手册对这寄存器是保留RSVD
wrOV7670Reg(0xb1, 0x0c);
wrOV7670Reg(0xb2, 0x0e);
wrOV7670Reg(0xb3, 0x82);
wrOV7670Reg(0xb8, 0x0a);
// //SCALING_xx寄存器
// wrOV7670Reg(0x70, 0x00);
// wrOV7670Reg(0x71, 0x00);
// wrOV7670Reg(0x72, 0x11);
// wrOV7670Reg(0x73, 0x08);
// wrOV7670Reg(0x3e, 0x00);
// //ADC
// wrOV7670Reg(0x37, 0x1d); // ADC控制ADC Control
// wrOV7670Reg(0x38, 0x71); // ADC和模拟共模控制ADC and Analog Common Mode Control
// wrOV7670Reg(0x39, 0x2a); // ADC偏移控制ADC Offset Control
// //零杂的寄存器
// wrOV7670Reg(0x92, 0x00); // 空行低八位Dummy Line low 8 bits
// wrOV7670Reg(0xa2, 0x02); // 像素时钟延时
// wrOV7670Reg(0x0c, 0x0c);
// wrOV7670Reg(0x10, 0x00);
// wrOV7670Reg(0x0d, 0x01);
// wrOV7670Reg(0x0f, 0x4b);
// wrOV7670Reg(0x3c, 0x78);
// wrOV7670Reg(0x74, 0x19);
// //用户手册里这几个寄存器都是保留RSVD
// wrOV7670Reg(0x0e, 0x61);
// wrOV7670Reg(0x16, 0x02);
// wrOV7670Reg(0x21, 0x02);
// wrOV7670Reg(0x22, 0x91);
// wrOV7670Reg(0x29, 0x07);
// wrOV7670Reg(0x33, 0x0b);
// wrOV7670Reg(0x35, 0x0b);
// wrOV7670Reg(0x4d, 0x40);
// wrOV7670Reg(0x4e, 0x20);
// wrOV7670Reg(0x8d, 0x4f);
// wrOV7670Reg(0x8e, 0x00);
// wrOV7670Reg(0x8f, 0x00);
// wrOV7670Reg(0x90, 0x00);
// wrOV7670Reg(0x91, 0x00);
// wrOV7670Reg(0x96, 0x00);
// wrOV7670Reg(0x9a, 0x80);
}
</code>
离线