微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > STM32直接驱动ov7670 开发笔记

STM32直接驱动ov7670 开发笔记

时间:11-11 来源:互联网 点击:

45,0x34},

{0x46,0x58},

{0x47,0x28},

{0x48,0x3a},

{0x59,0x88},

{0x5a,0x88},

{0x5b,0x44},

{0x5c,0x67},

{0x5d,0x49},

{0x5e,0x0e},

{0x64,0x04},

{0x65,0x20},

{0x66,0x05},

{0x94,0x04},

{0x95,0x08},

{0x6c,0x0a},

{0x6d,0x55},

{0x6e,0x11},

{0x6f,0x9f},//0x9e for advanced AWB

{0x6a,0x40},

{0x01,0x40},

{0x02,0x40},

{0x13,0xe7},

{0x4f,0x86},//80/86/8c/93/99

{0x50,0x86},//80/86/8c/93/99

{0x51,0x00},//00/00/00/00/00

{0x52,0x23},//22/23/25/27/28

{0x53,0x62},//5e/62/67/6c/70

{0x54,0x86},//80/86/8c/93/99

{0x58,0x9e},

{0x41,0x08},

{0x3f,0x1f},//边缘增强调整 位[4:0]:边缘增强系数

{0x75,0x10},//位[4:0]:边缘增强下限 0x0f

{0x76,0xc0},//位[4:0]:边缘增强上限 0x01

{0x4c,0xff},//噪声抑制强度

{0x77,0x01},

{0x3d,0xc2},//110000010 位[6]:UV饱和度标准-UV自动调整

{0x4b,0x09},

{0xc9,0xf0},//饱和度控制

{0x41,0x3a},//针对YUV边缘增强阈值自动调整 AWB增益使能

{0x34,0x11},

{0x3b,0x0a},

{0xa4,0x88},

{0x96,0x00},

{0x97,0x30},

{0x98,0x20},

{0x99,0x30},

{0x9a,0x84},

{0x9b,0x29},

{0x9c,0x03},

{0x9d,0x4b},

{0x9e,0x3f},

{0x78,0x04},

{0x79,0x01},

{0xc8,0xf0},

{0x79,0x0f},

{0xc8,0x00},

{0x79,0x10},

{0xc8,0x7e},

{0x79,0x0a},

{0xc8,0x80},

{0x79,0x0b},

{0xc8,0x01},

{0x79,0x0c},

{0xc8,0x0f},

{0x79,0x0d},

{0xc8,0x20},

{0x79,0x09},

{0xc8,0x80},

{0x79,0x02},

{0xc8,0xc0},

{0x79,0x03},

{0xc8,0x40},

{0x79,0x05},

{0xc8,0x30},

{0x79,0x26},

{0x2d,0x00},

{0x2e,0x00},

这个配置表一般就可以出图像了,或许你还出不来的话就得看看你用的STM32是不是fsmc接口驱动的lcd,如果不是那就99%不行了。有了配置表我在把主函数贴出来,大家可以改进算法,最近也没时间再改进了(因为我最终的任务是驱动CCD所以cmos只是一个过场);想要提高水品还得靠自己。

主程序(关键代码):

void main(void)

{

uint32_t PCnt=0;

static uint8_t Cnt= 0;

u16 value=0,val1=0,val2=0,REG=0;

/**************************/

SysTick_Init();

TIME2_Init( );

START_TIME;

Init_CCD_OV7670( );

LCD_Init();

Delay_us(20);

LCD_REG=R34;

CCD_EXTI_Init( );

while(1)

{

PCnt = 0;

Cnt = 1;

XClock_Init( ); //OV7670 XCLK 开 (我用的是TIM2产生PWM波,开关只要改变相应引脚状态就好了)

while(value & 0x0004) value = GPIOE->IDR; // Vsync=H

while(~value & 0x0004) value = GPIOE->IDR; // Vsync=L

XClock_OUT(); //OV7670 XCLK 关

/*******直接使用时钟时要加一个低电平*************

*不然会把第一个字节丢掉,产生反色或者是花纹的现象

*正常数据 (R G B) (R G B) (R G B )

*丢失第一字节 (G B R) (G B R) (G B

************************************************/

XCLK_L;

while(PCnt<76800)

{

XCLK_H;

XCLK_L;

REG = GPIOE->IDR;

if(REG&0x0002) // HREF = H 水平信号高时有数据

{

if(REG&0x0001){ //PCLK = H 再次判断像素时钟是不是高

value = GPIOC->IDR;

if((Cnt == 1))// 高字节

{

val1=(value<8);

Cnt=0;

}

else // 低字节

{

val2=(value&0x00ff);

Cnt = 1;

LCD_RAM =val1 |val2; //(我用的是fsmc接口所以才可以这样写)

PCnt ++;

}

}

}

}

}

}

//快的时钟一定要用定时器的PWM功能,定时器中断翻转电平是无法实现的,切记。

好了就写这么多,应该对大家有帮助。


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top