FPGA学习日志
鼓励自己每天进行学习总结:2021.2.6
找到了ov7670寄存器的配置具体介绍
转载自:
OV7670配置和调试总结——浩爹
SCCB协议介绍与应用和OV7670摄像头的寄存器配置——emperor_strange
const uint8_t OV7670_Reg[][2]=
{
//Frame Rate Adjustment for 24Mhz input clock
//30fps PCLK=24MHz
{0x11, 0x80},//软件应用手册上设置的是0x80,例程设置的是0x00
{0x6b, 0x0a},//PLL控制,软件应用手册上设置的是0x0a,例程设置的是0x40,将PLL调高的话就会产生花屏
{0x2a, 0x00},
{0x2b, 0x00},
{0x92, 0x00},
{0x93, 0x00},
{0x3b, 0x0a},
//Output format
{0x12, 0x14},//QVGA(320*240)、RGB
//RGB555/565 option(must set COM7[2] = 1 and COM7[0] = 0)
{0x40, 0x10},//RGB565,effective only when RGB444[1] is low
{0x8c, 0x00},
//Special effects – 特效
//normal
{0x3a, 0x04},
{0x67, 0xc0},
{0x68, 0x80},
//Mirror/VFlip Enable – 水平镜像/竖直翻转使能
{0x1e, 0x37},//修改配置值将产生图像显示上下或左右颠倒
//Banding Filter Setting for 24Mhz Input Clock – 条纹滤波器
//30fps for 60Hz light frequency
//{0x13, 0xe7},//banding filer enable
//{0x9d, 0x98},//50Hz banding filer
//{0x9e, 0x7f},//60Hz banding filer
//{0xa5, 0x02},//3 step for 50Hz
//{0xab, 0x03},//4 step for 60Hz
//{0x3b, 0x02},//select 60Hz banding filer
//Simple White Balance – 白平衡
//{0x13, 0xe7},//AWB、AGC、AGC Enable and …
//{0x6f, 0x9f},//simple AWB
//AWBC – 自动白平衡控制(Automatic white balance control)
//{0x43, 0x14},//用户手册里这些寄存器的值都是保留(Reserved),不用设置的呀?
//{0x44, 0xf0},
//{0x45, 0x34},
//{0x46, 0x58},
//{0x47, 0x28},
//{0x48, 0x3a},
//AWB Control
//{0x59, 0x88},//用户手册连寄存器都是保留,初始值都没提供
//{0x5a, 0x88},
//{0x5b, 0x44},
//{0x5c, 0x67},
//{0x5d, 0x49},
//{0x5e, 0x0e},
//AWB Control
//{0x6c, 0x0a},
//{0x6d, 0x55},
//{0x6e, 0x11},
//{0x6f, 0x9f},
//AGC/AEC – Automatic Gain Control自动增益补偿/Automatic exposure Control自动曝光控制
//{0x00, 0x00},
//{0x14, 0x20},
//{0x24, 0x75},
//{0x25, 0x63},
//{0x26, 0xA5},
//AEC algorithm selection – AEC公式选择
//{0xaa, 0x94},//基于平均值的AEC算法Average-based AEC algorithm/基于直方图的AEC算法Histogram-based AEC algorithm
//基于直方图的AGC/AEC的控制
//{0x9f, 0x78},
//{0xa0, 0x68},
//{0xa6, 0xdf},
//{0xa7, 0xdf},
//{0xa8, 0xf0},
//{0xa9, 0x90},
//Fix Gain Control – 固定增益控制
//{0x69, 0x5d},//Fix gain for Gr channel/for Gb channel/for R channel/for B channel
//Color saturation 颜色饱和度 + 0
//{0x4f, 0x80},
//{0x50, 0x80},
//{0x51, 0x00},
//{0x52, 0x22},
//{0x53, 0x5e},
//{0x54, 0x80},
//{0x58, 0x9e},
//Brightness – 亮度 + 0
//{0x55, 0x00},
//Contrast – 对比度 + 0
//{0x56, 0x40},
//Gamma Curve – 伽马曲线
//{0x7a, 0x20},
//{0x7b, 0x1c},
//{0x7c, 0x28},
//{0x7d, 0x3c},
//{0x7e, 0x55},
//{0x7f, 0x68},
//{0x80, 0x76},
//{0x81, 0x80},
//{0x82, 0x88},
//{0x83, 0x8f},
//{0x84, 0x96},
//{0x85, 0xa3},
//{0x86, 0xaf},
//{0x87, 0xc4},
//{0x88, 0xd7},
//{0x89, 0xe8},
//Matrix Coefficient – 色彩矩阵系数
//{0x4f, 0x80},
//{0x50, 0x80},
//{0x51, 0x00},
//{0x52, 0x22},
//{0x53, 0x5e},
//{0x54, 0x80},
//Lens Correction Option – 镜头补偿选项
//{0x62, 0x00},
//{0x63, 0x00},
//{0x64, 0x04},
//{0x65, 0x20},
//{0x66, 0x05},
//{0x94, 0x04},//effective only when LCC5[2] is high
//{0x95, 0x08},//effective only when LCC5[2] is high
//注释这些配置的话,就倾斜显示,并显示多块,这到底是控制什么的?跟时序图有关?
{0x17, 0x16},//行频Horizontal Frame开始高八位(低三位在HREF[2:0])
{0x18, 0x04},//行频Horizontal Frame结束高八位(低三位在HREF[5:3])
{0x19, 0x02},//场频Vertical Frame开始高八位(低二位在VREF[1:0])
{0x1a, 0x7b},//场频Vertical Frame结束高八位(低二位在VREF[3:2])
{0x32, 0x80},//HREF
{0x03, 0x06},//VREF
//注释这个配置的话,就显示花屏了
{0x15, 0x02},//配置PCLK、HREF、VSYNC相关
//Automatic black Level Compensation – 自动黑电平校正
{0xb0, 0x84},//调试时注释这项配置时,颜色显示不正常了,红色练绿色,绿色变红色,但用户手册对这寄存器是保留RSVD
//{0xb1, 0x0c},
//{0xb2, 0x0e},
//{0xb3, 0x82},
//{0xb8, 0x0a},
//SCALING_xx寄存器
//{0x70, 0x00},
//{0x71, 0x00},
//{0x72, 0x11},
//{0x73, 0x08},
//{0x3e, 0x00},
//ADC
//{0x37, 0x1d},//ADC控制ADC Control
//{0x38, 0x71},//ADC和模拟共模控制ADC and Analog Common Mode Control
//{0x39, 0x2a},//ADC偏移控制ADC Offset Control
//零杂的寄存器
//{0x92, 0x00},//空行低八位Dummy Line low 8 bits
//{0xa2, 0x02},//像素时钟延时
//{0x0c, 0x0c},
//{0x10, 0x00},
//{0x0d, 0x01},
//{0x0f, 0x4b},
//{0x3c, 0x78},
//{0x74, 0x19},
//用户手册里这几个寄存器都是保留RSVD
//{0x0e, 0x61},
//{0x16, 0x02},
//{0x21, 0x02},
//{0x22, 0x91},
//{0x29, 0x07},
//{0x33, 0x0b},
//{0x35, 0x0b},
//{0x4d, 0x40},
//{0x4e, 0x20},
//{0x8d, 0x4f},
//{0x8e, 0x00},
//{0x8f, 0x00},
//{0x90, 0x00},
//{0x91, 0x00},
//{0x96, 0x00},
//{0x9a, 0x80},
}
parameter REG_NUM = 165;
always@(*) begincase(reg_cnt)0 : add_wdata = {2'b11,16'h1204};//复位,VGA,RGB565 (00:YUV,04:RGB)(8x全局复位)1 : add_wdata = {2'b11,16'h40d0}; //RGB565, 00-FF(d0)(YUV下要攱-FE(80))2 : add_wdata = {2'b11,16'h3a04}; //TSLB(TSLB[3], COM13[0])00:YUYV, 01:YVYU, 10:UYVY(CbYCrY), 11:VYUY3 : add_wdata = {2'b11,16'h3dc8}; //COM13(TSLB[3], COM13[0])00:YUYV, 01:YVYU, 10:UYVY(CbYCrY), 11:VYUY4 : add_wdata = {2'b11,16'h1e31}; //默认01,Bit[5]水平镜像,Bit[4]竖直镜像5 : add_wdata = {2'b11,16'h6b00}; //旁路PLL倍频ク0A:关闭内部LDOク00:打开LDO6 : add_wdata = {2'b11,16'h32b6}; //HREF 控制(80)7 : add_wdata = {2'b11,16'h1713}; //HSTART 输出格式-行频开始高8位8 : add_wdata = {2'b11,16'h1801}; //HSTOP 输出格式-行频结束9 : add_wdata = {2'b11,16'h1902}; //VSTART 输出格式-场频开始高8位10 : add_wdata = {2'b11,16'h1a7a}; //VSTOP 输出格式-场频结束11 : add_wdata = {2'b11,16'h030a}; //VREF 帧竖直方向控到0)12 : add_wdata = {2'b11,16'h0c00}; //DCW使能 禁止(00)13 : add_wdata = {2'b11,16'h3e10}; //PCLK分频00 Normal 14 : add_wdata = {2'b11,16'h7000}; //00:Normal, 80:移位1, 00:彩条, 80:渐变彩条15 : add_wdata = {2'b11,16'h7100}; //00:Normal, 00:移位1, 80:彩条, 80:渐变彩杊 16 : add_wdata = {2'b11,16'h7211}; //默认 水平,垂直采样(11) 17 : add_wdata = {2'b11,16'h7300}; //DSP缩放时钟分频00 18 : add_wdata = {2'b11,16'ha202}; //默认 像素始终延迟 (02)19 : add_wdata = {2'b11,16'h1180}; //内部工作时钟设置,直接使用外部时钟源(80)20 : add_wdata = {2'b11,16'h7a20};21 : add_wdata = {2'b11,16'h7b1c};22 : add_wdata = {2'b11,16'h7c28};23 : add_wdata = {2'b11,16'h7d3c};24 : add_wdata = {2'b11,16'h7e55};25 : add_wdata = {2'b11,16'h7f68};26 : add_wdata = {2'b11,16'h8076};27 : add_wdata = {2'b11,16'h8180};28 : add_wdata = {2'b11,16'h8288};29 : add_wdata = {2'b11,16'h838f};30 : add_wdata = {2'b11,16'h8496};31 : add_wdata = {2'b11,16'h85a3};32 : add_wdata = {2'b11,16'h86af};33 : add_wdata = {2'b11,16'h87c4};34 : add_wdata = {2'b11,16'h88d7};35 : add_wdata = {2'b11,16'h89e8};36 : add_wdata = {2'b11,16'h13e0};37 : add_wdata = {2'b11,16'h0010};//38 : add_wdata = {2'b11,16'h1000};39 : add_wdata = {2'b11,16'h0d00};40 : add_wdata = {2'b11,16'h1428}; 41 : add_wdata = {2'b11,16'ha505};42 : add_wdata = {2'b11,16'hab07};43 : add_wdata = {2'b11,16'h2475};44 : add_wdata = {2'b11,16'h2563};45 : add_wdata = {2'b11,16'h26a5};46 : add_wdata = {2'b11,16'h9f78};47 : add_wdata = {2'b11,16'ha068};48 : add_wdata = {2'b11,16'ha103};49 : add_wdata = {2'b11,16'ha6df};50 : add_wdata = {2'b11,16'ha7df};51 : add_wdata = {2'b11,16'ha8f0};52 : add_wdata = {2'b11,16'ha990};53 : add_wdata = {2'b11,16'haa94};54 : add_wdata = {2'b11,16'h13ef}; 55 : add_wdata = {2'b11,16'h0e61};56 : add_wdata = {2'b11,16'h0f4b};57 : add_wdata = {2'b11,16'h1602};58 : add_wdata = {2'b11,16'h2102};59 : add_wdata = {2'b11,16'h2291};60 : add_wdata = {2'b11,16'h2907};61 : add_wdata = {2'b11,16'h330b};62 : add_wdata = {2'b11,16'h350b};63 : add_wdata = {2'b11,16'h371d};64 : add_wdata = {2'b11,16'h3871};65 : add_wdata = {2'b11,16'h392a};66 : add_wdata = {2'b11,16'h3c78};67 : add_wdata = {2'b11,16'h4d40};68 : add_wdata = {2'b11,16'h4e20};69 : add_wdata = {2'b11,16'h6900};70 : add_wdata = {2'b11,16'h7419};71 : add_wdata = {2'b11,16'h8d4f};72 : add_wdata = {2'b11,16'h8e00};73 : add_wdata = {2'b11,16'h8f00};74 : add_wdata = {2'b11,16'h9000};75 : add_wdata = {2'b11,16'h9100};76 : add_wdata = {2'b11,16'h9200};77 : add_wdata = {2'b11,16'h9600};78 : add_wdata = {2'b11,16'h9a80};79 : add_wdata = {2'b11,16'hb084};80 : add_wdata = {2'b11,16'hb10c};81 : add_wdata = {2'b11,16'hb20e};82 : add_wdata = {2'b11,16'hb382};83 : add_wdata = {2'b11,16'hb80a};84 : add_wdata = {2'b11,16'h4314};85 : add_wdata = {2'b11,16'h44f0};86 : add_wdata = {2'b11,16'h4534};87 : add_wdata = {2'b11,16'h4658};88 : add_wdata = {2'b11,16'h4728};89 : add_wdata = {2'b11,16'h483a};90 : add_wdata = {2'b11,16'h5988};91 : add_wdata = {2'b11,16'h5a88};92 : add_wdata = {2'b11,16'h5b44};93 : add_wdata = {2'b11,16'h5c67};94 : add_wdata = {2'b11,16'h5d49};95 : add_wdata = {2'b11,16'h5e0e};96 : add_wdata = {2'b11,16'h6404};97 : add_wdata = {2'b11,16'h6520};98 : add_wdata = {2'b11,16'h6605};99 : add_wdata = {2'b11,16'h9404};100 : add_wdata = {2'b11,16'h9508};101 : add_wdata = {2'b11,16'h6c0a};102 : add_wdata = {2'b11,16'h6d55};103 : add_wdata = {2'b11,16'h6e11};104 : add_wdata = {2'b11,16'h6f9f};105 : add_wdata = {2'b11,16'h6a40};106 : add_wdata = {2'b11,16'h0140};107 : add_wdata = {2'b11,16'h0240};108 : add_wdata = {2'b11,16'h13e7};109 : add_wdata = {2'b11,16'h1500};110 : add_wdata = {2'b11,16'h4f80};111 : add_wdata = {2'b11,16'h5080};112 : add_wdata = {2'b11,16'h5100};113 : add_wdata = {2'b11,16'h5222};114 : add_wdata = {2'b11,16'h535e};115 : add_wdata = {2'b11,16'h5480};116 : add_wdata = {2'b11,16'h589e};117 : add_wdata = {2'b11,16'h4108};118 : add_wdata = {2'b11,16'h3f00};119 : add_wdata = {2'b11,16'h7505};120 : add_wdata = {2'b11,16'h76e1};121 : add_wdata = {2'b11,16'h4c00};122 : add_wdata = {2'b11,16'h7701};123 : add_wdata = {2'b11,16'h4b09};124 : add_wdata = {2'b11,16'hc9F0};//16'hc960;125 : add_wdata = {2'b11,16'h4138};126 : add_wdata = {2'b11,16'h5640};127 : add_wdata = {2'b11,16'h3411};128 : add_wdata = {2'b11,16'h3b02};129 : add_wdata = {2'b11,16'ha489};130 : add_wdata = {2'b11,16'h9600};131 : add_wdata = {2'b11,16'h9730};132 : add_wdata = {2'b11,16'h9820};133 : add_wdata = {2'b11,16'h9930};134 : add_wdata = {2'b11,16'h9a84};135 : add_wdata = {2'b11,16'h9b29};136 : add_wdata = {2'b11,16'h9c03};137 : add_wdata = {2'b11,16'h9d4c};138 : add_wdata = {2'b11,16'h9e3f};139 : add_wdata = {2'b11,16'h7804};140 :add_wdata = {2'b11,16'h7901};141 :add_wdata = {2'b11,16'hc8f0};142 :add_wdata = {2'b11,16'h790f};143 :add_wdata = {2'b11,16'hc800};144 :add_wdata = {2'b11,16'h7910};145 :add_wdata = {2'b11,16'hc87e};146 :add_wdata = {2'b11,16'h790a};147 :add_wdata = {2'b11,16'hc880};148 :add_wdata = {2'b11,16'h790b};149 :add_wdata = {2'b11,16'hc801};150 :add_wdata = {2'b11,16'h790c};151 :add_wdata = {2'b11,16'hc80f};152 :add_wdata = {2'b11,16'h790d};153 :add_wdata = {2'b11,16'hc820};154 :add_wdata = {2'b11,16'h7909};155 :add_wdata = {2'b11,16'hc880};156 :add_wdata = {2'b11,16'h7902};157 :add_wdata = {2'b11,16'hc8c0};158 :add_wdata = {2'b11,16'h7903};159 :add_wdata = {2'b11,16'hc840};160 :add_wdata = {2'b11,16'h7905};161 :add_wdata = {2'b11,16'hc830}; 162 :add_wdata = {2'b11,16'h7926};163 : add_wdata = {2'b11,16'h0903};164 : add_wdata = {2'b11,16'h3b42};default : add_wdata = 0;endcaseend