OV7725寄存器配置_i2c总线通信距离

2022-11-09 20:40:41 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

OV7725寄存器配置(为了替换NT99141研究了很长一段时间)

部分参考链接: OV7725 电器特性和时序图:https://www.cnblogs.com/raymon-tec/p/5087088.html OV7725摄像头的彩色图像采集原理与液晶显示(有必要了解框图):https://blog.csdn.net/huzhoudaxia/article/details/75269392

OV7725的一些必要认识

XCLK:工作时钟输入,由主控器产生(由外部输入到摄像头),频率常用为24MHz; PCLK:像素时钟输出,由XCLK产生,用于控制器采样图像数据(时钟速率<5ns,比如PCL84MHZ,30fps); 配置寄存器设置不同频率 HREF:行参考信号输出; VSYNC:场同步信号输出; 一帧图像产生的中断,配置寄存器可使用该功能

D[9:0] 像素数据输出;

RSTB:复位输入,低电平有效; PWDN:低功耗模式选择输入,正常工作期间需拉低; SCL:SCCB管理接口时钟,最高频率400KHz; SDA:SCCB接口串行数据总线;

OV7725寄存器配置(引自野火的配置)

代码语言:javascript复制
//寄存器宏定义
#define GAIN      0x00
#define BLUE      0x01
#define RED       0x02
#define GREEN     0x03
#define BAVG      0x05
#define GAVG      0x06
#define RAVG      0x07
#define AECH      0x08
#define COM2      0x09
#define PID       0x0A
#define VER       0x0B
#define COM3      0x0C
#define COM4      0x0D
#define COM5      0x0E
#define COM6      0x0F
#define AEC       0x10
#define CLKRC     0x11
#define COM7      0x12
#define COM8      0x13
#define COM9      0x14
#define COM10     0x15
#define REG16     0x16
#define HSTART    0x17
#define HSIZE     0x18
#define VSTRT     0x19
#define VSIZE     0x1A
#define PSHFT     0x1B
#define MIDH      0x1C
#define MIDL      0x1D
#define RSVD      0x1E
#define LAEC      0x1F
#define COM11     0x20
#define BDBase    0x22
#define BDMStep   0x23
#define AEW       0x24
#define AEB       0x25
#define VPT       0x26
#define REG28     0x28
#define HOutSize  0x29
#define EXHCH     0x2A
#define EXHCL     0x2B
#define VOutSize  0x2C
#define ADVFL     0x2D
#define ADVFH     0x2E
#define YAVE      0x2F
#define LumHTh    0x30
#define LumLTh    0x31
#define HREF      0x32
#define DM_LNL    0x33
#define DM_LNH    0x34
#define ADoff_B   0x35
#define ADoff_R   0x36
#define ADoff_Gb  0x37
#define ADoff_Gr  0x38
#define Off_B     0x39
#define Off_R     0x3A
#define Off_Gb    0x3B
#define Off_Gr    0x3C
#define COM12     0x3D
#define COM13     0x3E
#define COM14     0x3F
#define COM15     0x40
#define COM16     0x41
#define TGT_B     0x42
#define TGT_R     0x43
#define TGT_Gb    0x44
#define TGT_Gr    0x45
#define LC_CTR    0x46
#define LC_XC     0x47
#define LC_YC     0x48
#define LC_COEF   0x49
#define LC_RADI   0x4A
#define LC_COEFB  0x4B 
#define LC_COEFR  0x4C
#define FixGain   0x4D
#define AREF0     0x4E
#define AREF1     0x4F
#define AREF2     0x50
#define AREF3     0x51
#define AREF4     0x52
#define AREF5     0x53
#define AREF6     0x54
#define AREF7     0x55
#define UFix      0x60
#define VFix      0x61
#define AWBb_blk  0x62
#define AWB_Ctrl0 0x63
#define DSP_Ctrl1 0x64
#define DSP_Ctrl2 0x65
#define DSP_Ctrl3 0x66
#define DSP_Ctrl4 0x67
#define AWB_bias  0x68
#define AWBCtrl1  0x69
#define AWBCtrl2  0x6A
#define AWBCtrl3  0x6B
#define AWBCtrl4  0x6C
#define AWBCtrl5  0x6D
#define AWBCtrl6  0x6E
#define AWBCtrl7  0x6F
#define AWBCtrl8  0x70
#define AWBCtrl9  0x71
#define AWBCtrl10 0x72
#define AWBCtrl11 0x73
#define AWBCtrl12 0x74
#define AWBCtrl13 0x75
#define AWBCtrl14 0x76
#define AWBCtrl15 0x77
#define AWBCtrl16 0x78
#define AWBCtrl17 0x79
#define AWBCtrl18 0x7A
#define AWBCtrl19 0x7B
#define AWBCtrl20 0x7C
#define AWBCtrl21 0x7D 
#define GAM1      0x7E
#define GAM2      0x7F
#define GAM3      0x80
#define GAM4      0x81
#define GAM5      0x82
#define GAM6      0x83
#define GAM7      0x84
#define GAM8      0x85
#define GAM9      0x86
#define GAM10     0x87
#define GAM11     0x88
#define GAM12     0x89
#define GAM13     0x8A
#define GAM14     0x8B
#define GAM15     0x8C
#define SLOP      0x8D
#define DNSTh     0x8E
#define EDGE0     0x8F
#define EDGE1     0x90
#define DNSOff    0x91
#define EDGE2     0x92
#define EDGE3     0x93
#define MTX1      0x94
#define MTX2      0x95
#define MTX3      0x96
#define MTX4      0x97
#define MTX5      0x98
#define MTX6      0x99
#define MTX_Ctrl  0x9A
#define BRIGHT    0x9B
#define CNST      0x9C
#define UVADJ0    0x9E
#define UVADJ1    0x9F
#define SCAL0     0xA0
#define SCAL1     0xA1
#define SCAL2     0xA2
#define SDE       0xA6
#define USAT      0xA7
#define VSAT      0xA8
#define HUECOS    0xA9
#define HUESIN    0xAA
#define SIGN      0xAB
#define DSPAuto   0xAC
//寄存器配置表
static Register_Info Sensor_Config[] =
{
{COM7,      0x80}, //恢复默认设置
{COM10,     0x02},//激活场中断
/*输出格式,分辨率配置*/
{CLKRC,		0x00}, /*clock config*/
{COM7,		0x00}, /*VGA RGB422 */
{HSTART, 	0x23}, //VGA = 0x23,QVGA = 0x3F 
{HSIZE, 	0xA0}, //VGA = 0xA0,QVGA = 0X50
{VSTRT, 	0x07}, //VGA = 0x07,QVGA = 0X03
{VSIZE, 	0xf0}, //VGA = 0xf0,QVGA = 0X78
{HREF, 		0x00},
{HOutSize, 	0xA0},
{VOutSize, 	0xF0},
{EXHCH, 	0x00},
/*DSP control*/
{TGT_B,		0x7f},
{FixGain,	0x09},
{AWB_Ctrl0,	0xe0},
{DSP_Ctrl1,	0xff},
{DSP_Ctrl2,	0x20},
{DSP_Ctrl3,	0x00},
{DSP_Ctrl4,	0x00},
/*AGC AEC AWB*/
{COM8,		0xf0},
{COM4,		0x41},	  /*Pll AEC CONFIG,对输出颜色有影响*/
{COM6,		0xc5},
{COM9,		0x21},
{AEW,		0x34},
{AEB,		0x3c},
{VPT,		0xa1},
{EXHCL,		0x00},
{AWBCtrl3,	0xaa},
{AWBCtrl1,	0x5d},
{EDGE1,		0x0a},
{DNSOff,	0x01},
{MTX1,		0x5f},
{MTX2,		0x53},
{MTX3,		0x11},
{MTX4,		0x1a},
{MTX5,		0x3d},
{MTX6,		0x5a},
{MTX_Ctrl,	0x1e},
{BRIGHT,	0x00},
{CNST,		0x25},
{USAT,		0x65},
{VSAT,		0x65},
{UVADJ0,	0x81},
{SDE,		0x20},  //二值化,个人需求,根据寄存器手册进行配置,这个寄存器还有其他功能,可以多看看
/*GAMMA config*/
{GAM1,		0x0c},
{GAM2,		0x16},
{GAM3,		0x2a},
{GAM4,		0x4e},
{GAM5,		0x61},
{GAM6,		0x6f},
{GAM7,		0x7b},
{GAM8,		0x86},
{GAM9,		0x8e},
{GAM10,		0x97},
{GAM11,		0xa4},
{GAM12,		0xaf},
{GAM13,		0xc5},
{GAM14,		0xd7},
{GAM15,		0xe8},
{SLOP,		0x20},
{HUECOS,	0x80},
{HUESIN,	0x80},
{DSPAuto,	0xff},
{DM_LNL,	0x00},
{BDBase,	0x99},
{BDMStep,	0x03},
{LC_RADI,	0x00},
{LC_COEF,	0x13},
{LC_XC,		0x08},
{LC_COEFB,	0x14},
{LC_COEFR,	0x17},
{LC_CTR,	0x05},
/*Horizontal mirror image*/
{COM3,		0xd0},//垂直翻转,水平翻转
/*night mode auto frame rate control*/
//	{COM5,		0xf5},	/*在夜视环境下,自动降低帧率,保证低照度画面质量*/
{COM5,		0x31},	/*夜视环境帧率不变*/
}
//部分缩写解释:AGC(Auto maticGain Control):自动增益控制,AWB:自动白平衡,AEC(automatic exposure control):自动曝光控制,BLC(back light control):背光补偿

个人总结

OV7725的基本启动配置主要有时钟、分辨率、输出格式。

部分需要关注的寄存器:

COM3:可以换数据输出顺序,比如可以RGB顺序,也可以BGR顺序 COM4:PLL设置,影响帧率 COM8:AGC,AWB,WEC使能 COM10:行中断(HSYNC),场中断使能 还有上面分辨率配置那一块是很必要配置的

再说说我替换NT99141遇到的坑(不熟悉代码流程(开发板配套demo)带来的坑最多): 1…未激活场中断(或者说帧中断)。开发板缓存的采集依据估计是根据帧中断来的,开启过后,LCD上能够显示图像轮廓 2.XCLK输入超范围,采集图像不准确 3.寄存器配置PLL带来PCLK不匹配,图像也不准确 4.分辨率配置错误带来图像大小不准确 5.以为NT99141输出的是RGB565格式,导致LCD看到的图像是绿色的图像轮廓,这是坑我坑的最久的,被同事误导了一波,还得靠自己啊。

关于OV7725的其他功能,参见官方《OV7725 Software Application Note》,主要是摄像头的微调,白平衡,曝光量,帧率之类的。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/190097.html原文链接:https://javaforall.cn

0 人点赞