STM32直接驱动ov7670 开发笔记
经过我的调试发现,要成功的关键:首先是时钟的初始化,直接驱动时时钟设置和寄存器设定常理不一样(这有可能是因为直接驱动太慢的缘故)下面代码我会详细说明;第二个是图像数据的读取很容易丢失掉第一个字节,(这是很多花屏的原因,很重要很重)最后就会出现反色呀,有规律的花屏呀,图像不正常等等(有fifo的肯定就不会有这些情况);第三是增益控制,因为直接驱动速度是相当慢的所以得把增益关掉,如果图像全是白的,或者很红有可能就是这原因。第四就是图像窗口和图像格式的设置,下面我把寄存器配置贴出来,注意下面的代码只适合直接驱动方式(时钟由STM32产生)。
/**********很重要内部时钟分频如果是直接驱动必须为0x80(不知道为何 直接使用外部时钟颜色不对ox40时)原因是数据起始读取不对 (0x40是容易把第一个数据丢掉,要特别注意)****/
{0x11,(0x040|0x00)},
/********0x3a 和 0x3d *************/
/***0x3d com13 [1] 0x3a TSLB [3]
* 1 1 VYUY
********************************************/
{0x3a,0x04},//yuv输出顺序
{0x3d,0xc2},//110000010 位[6]:UV饱和度标准-UV自动调整
/********0X12 AND 0X40*************
*这两个决定了输出图像的格式
**********************************/
{0x12,0x14},//输出图片模式为QVGA RGB
{0X40,0xd0},//输出数据范围 rgb565使能
{0x1e,0x17},//水平镜像/竖直翻转使能 //0x17为正面 37是镜面
/****0x17 18 32 0x19 1a 0a *******
*开窗口的大小设置
***********************************/
{0x17,0x16},//hstart
{0x18,0x04},//hstop
{0x32,0x80},//href
{0x19,0x02},
{0x1a,0x7b},//0x7a
{0x03,0x0a},//帧竖直方向控制 0x0a
/**********************************/
{0x0c,0x00},//
{0x3e,0x00},//pclk分频
/***********
*图像和测试开关
************************/
{0x70,0x3a},//测试图案
{0x71,0x35},//测试图案 35
{0x72,0x11},//dcw控制 设置亚抽样率 320*240
{0x73,0xf0},//dsp缩放时钟f0 f0
{0x55,0x00},//亮度控制 0x00最亮 00
{0x56,0x80},//对比度控制 80
{0xa2,0x02},//像素始终延迟
{0x7a,0x20},//伽马校正
{0x7b,0x10},
{0x7c,0x1e},
{0x7d,0x35},
{0x7e,0x5a},
{0x7f,0x69},
{0x80,0x76},
{0x81,0x80},
{0x82,0x88},
{0x83,0x8f},
{0x84,0x96},
{0x85,0xa3},
{0x86,0xaf},
{0x87,0xc4},
{0x88,0xd7},
{0x89,0xe8},
{0x13,0xef},//agc/aec/awb使能 条纹滤波
/*********增益控制********
*慢速是要关掉
*******************************/
{0x00,0x00},//自动增益控制 ff
/****曝光值 该寄存器提供[9:2] 07 AEGHH[15:10] 04COM1[1:0]******/
{0x07,0x00},
{0x10,0x00},
{0x04,0x00},
{0x0d,0x00},//different 0x60 10
{0x42,0x40},//aec窗口 0x80
{0x14,0x18},//自动增益限度 固定aec/agc
{0xa5,0x08},//50Hz条纹滤波器步长限制 0x08
{0xab,0x08},//60Hz条纹滤波器步长限制 0x08
{0x24,0x75},//AGC/AEC-稳定运行区域(上限)
{0x25,0x63},//AGC/AEC-稳定运行区域(下限)
{0x26,0xd4},//AGC/AEC快速运行区域
{0x9f,0x78},
{0xa0,0x68},
{0xa1,0x03},
{0xa6,0xd8},
{0xa7,0xd8},
{0xa8,0xf0},
{0xa9,0x90},
{0xaa,0x14},
{0x13,0xe5},//打开agc aec
{0x0e,0x61},
{0x0f,0x4b},
{0x16,0x02},
{0x21,0x02},
{0x22,0x91},
{0x29,0x07},
{0x33,0x0b},
{0x35,0x0b},
{0x37,0x1d},
{0x38,0x71},
{0x39,0x2a},
{0x3c,0x78},
{0x4d,0x40},
{0x4e,0x20},
{0x69,0x00},//固定增益控制
/*****这个很重要 直接驱动时不能设为0x00***/
{0x6b,0x0a},//pll 内部ld0
{0x74,0x10},
{0x8d,0x4f},
{0x8e,0x00},
{0x8f,0x00},
{0x90,0x00},
{0x91,0x00},
{0x92,0x19},
{0x96,0x00},
{0x9a,0x80},
{0xb0,0x84},
{0xb1,0x0c},
{0xb2,0x0e},
{0xb3,0x82},
{0xb8,0x0a},
{0x43,0x0a},
{0x44,0xf0},
{0x
STM32驱动ov767 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)