智能车制作
标题:
ov7725摄像头初始化程序,请高手指导!!!
[打印本页]
作者:
star001
时间:
2012-1-6 10:48
标题:
ov7725摄像头初始化程序,请高手指导!!!
#include "SCCB.h"
//uchar SCCBBuffer[3]={0xC1,0x06,0x80}; //读设备0xC1 寄存器号0x06 (亮度)
//SCCBBuffer[0]=SubID+R(1)/W(0) SCCBBuffer[1]=RegID SCCBBuffer[2]=Value
#include "SCI.h"
byte change_reg[71][2]=
{
{0x32,0x00},
{0x2a,0x00},
{0x11,0x40},
{0x12,0x02},
{0x12,0x02},
{0x42,0x7f},
{0x4d,0x00},
{0x63,0xf0},
{0x64,0xff},
{0x65,0x20},
{0x66,0x00},
{0x67,0x00},
{0x69,0x5d},
{0x13,0xff},
{0x0d,0x00},
{0x0f,0xc5},
{0x14,0x11},
{0x22,0xFF},
{0x23,0x01},
{0x24,0x34},
{0x25,0x3c},
{0x26,0xa1},
{0x2b,0x00},
{0x6b,0xaa},
{0x13,0xff},
{0x90,0x0a},
{0x91,0x01},
{0x92,0x01},
{0x93,0x01},
{0x94,0x5f},
{0x95,0x53},
{0x96,0x11},
{0x97,0x1a},
{0x98,0x3d},
{0x99,0x5a},
{0x9a,0x1e},
{0x9b,0x00},
{0x9c,0x25},
{0xa7,0x65},
{0xa8,0x65},
{0xa9,0x80},
{0xaa,0x80},
{0x9e,0x81},
{0xa6,0x06},
{0x7e,0x0c},
{0x7f,0x16},
{0x80,0x2a},
{0x81,0x4e},
{0x82,0x61},
{0x83,0x6f},
{0x84,0x7b},
{0x85,0x86},
{0x86,0x8e},
{0x87,0x97},
{0x88,0xa4},
{0x89,0xaf},
{0x8a,0xc5},
{0x8b,0xd7},
{0x8c,0xe8},
{0x8d,0x20},
{0x33,0x00},
{0x22,0x99},
{0x23,0x03},
{0x4a,0x00},
{0x49,0x13},
{0x47,0x08},
{0x4b,0x14},
{0x4c,0x17},
{0x46,0x05},
{0x0e,0xf5},
{0x0c,0xd0},
};
void SCCB_Wait() //当前时钟下延时2us
{ uchar i;
for(i=0;i<3;i++){
asm nop;
asm nop;
asm nop;
asm nop;
asm nop;
asm nop;
asm nop;
asm nop;
asm nop;
asm nop;
}
}
void SCCB_Start(void)
{
SDA_DR=OUT;
SDA=1;
SCL=1;
SCCB_Wait();
SCCB_Wait();
SDA=0;
SCCB_Wait();
SCCB_Wait();
SCL=0;
}
void SCCB_Stop(void)
{ SDA_DR=OUT;
SDA=0;
SCCB_Wait();
SCL=1;
SCCB_Wait();
SDA=1;
SCCB_Wait();
}
void SCCB_Send_ACK(void)
{
SDA_DR=OUT;
SDA=0;
SCL=1;
SCCB_Wait();
SCL=0;
}
uchar SCCB_Send_Byte(uchar ch)
{ uchar i;
SDA_DR=OUT;
for(i=0;i<8;i++){
if(ch & 0x80) SDA=1;
else SDA=0;
ch <<=1;
SCCB_Wait();
SCL=1;
SCCB_Wait();
SCCB_Wait();
SCL=0;
SCCB_Wait();
}
SDA=1;
SDA_DR=IN;
SCCB_Wait();
SCL=1;
SCCB_Wait();
i=SDA; //检测ACK信号是否为0(避免过多定义变量,所有就用i)
SCL=0;
SCCB_Wait();
return i;
}
uchar SCCB_Recieve_Byte(void)
{ uchar i;
uchar Recieve_Data=0;
SDA_DR=IN;
for(i=0;i<8;i++){
SCL=1;
SCCB_Wait();
Recieve_Data <<=1;
if(SDA) Recieve_Data|=0x01;
SCL=0;
SCCB_Wait();
}
return Recieve_Data;
}
uchar SCCB_Read(uchar addr,uchar reg)
{
uchar Read_Data;
SCCB_Start();
if(SCCB_Send_Byte(addr & 0xFE)){
SCCB_Stop();
return 0x81;
}
if(SCCB_Send_Byte(reg)){ //写阶段
SCCB_Stop();
return 0x82;
}
SCCB_Stop();
SCCB_Start();
if(SCCB_Send_Byte(addr | 0x01)){
SCCB_Stop();
return 0x83;
}
Read_Data=SCCB_Recieve_Byte();
SCCB_Stop();
return Read_Data;
}
uchar SCCB_Write(uchar addr,uchar reg,uchar value)
{ SCCB_Start();
if(SCCB_Send_Byte(addr & 0xFE)){
SCCB_Stop();
return 1;
}
if(SCCB_Send_Byte(reg)){
SCCB_Stop();
return 1;
}
if(SCCB_Send_Byte(value)){
SCCB_Stop();
return 1;
}
SCCB_Stop();
return 0;
}
void SCCB_Init(void)
{
byte k,y;
SCL_DR=OUT;
SDA_DR=OUT;
PERT_PERT4=1;
PPST_PPST4=0;
SCCB_Write(0x42,0x12,0x80) ;
for(k=0;k<71;k++) {
//SCCB_Write(0x42,0x0C,0x20) ;
// SCCB_Write(0x42,0x64,0xFF) ;
// SCCB_Write(0x42,0x65,0x20) ;
SCCB_Write(0x42,change_reg[k][0],change_reg[k][1]) ;
// PIEH_PIEH2 = 0;
// PIEH_PIEH3 = 0;
}
while(0){
SCI_Write(0xAA);
SCI_Write(0xAA) ;
SCI_Write(0xAA);
SCI_Write(0xAA) ;
for(k=0;k<71;k++){
SCI_Write(0xAA) ;
SCI_Write(change_reg[k][0]);
SCI_Write(SCCB_Read(0x43,change_reg[k][0]));
}
}
}
作者:
star001
时间:
2012-1-6 10:49
采用mc9s12xs128
作者:
lsa123
时间:
2012-1-26 00:53
我也是用7725,楼主你是自己写的还是送的例程,我也还没有调出图像,要不交流下代码
作者:
wangzhe330
时间:
2012-2-16 22:14
你的7725带FIFO吗
作者:
dongfangzi
时间:
2012-2-27 23:03
作者:
xuezihan
时间:
2012-3-9 20:32
准备使用OV7725
作者:
ROB星空
时间:
2014-10-13 22:22
同样OV7725的围观
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2