本帖最后由 feiyinglala 于 2016-6-2 08:59 编辑
用stm32f051用IO口直接驱动没有fifo的OV7670,现在问题是,在彩条测试模式,读出的画面颜色不正常。摄像头配置为 QVGA RGB565 ,而且一行像素应该是有640字节,可是现在读出的有效数据为315个像素点.最后15个像素读出的又到了下一行数据,见数据包
彩条测试模式
这是正常模式读出的画面
附摄像头寄存器配置
{0x3a, 0x04},//VYUY/UYVY|TSLB(行缓冲测试选项):[5]-负片,[4]UV输出数据,[3]输出顺序,【0】自动输出窗口】
{0x40, 0xd0},//RGB565|COM15(通用控制15):
{0x12, 0x16},//QVGA,RGB输出|COM7(通用控制7):
//输出窗口设置:HSATRT-184 HSTOP-40 VSTART-10 VSTOP-490
{0x32, 0x80},//|HERF(HERF控制):[5:0]HREF结束开始的低3位
{0x17, 0x16},//|HSTART(行频开始高八位)
{0x18, 0x04},//|HSTOP(行频结束高八位)
{0x19, 0x02},//|VSTART(场频开始高八位)
{0x1a, 0x7b},//|VSTOP(场频结束高八位)
{0x03, 0x06},//|VREF(帧竖直方向控制):[3:0]VREF结束开始的低两位
{0x0c, 0x00},//COM3
{0x15, 0x00},//COM10
{0x3e, 0x00},//COM14[000x xxxx]:DCW,缩放参数,PCLK分频
{0x70, 0x00},//SCALING_XSC:00 无测试图案;01 移位1 3a
{0x71, 0x80},//SCALING_YSC:10 八色颜色条;11 渐变城灰色颜色条 35
{0x72, 0x11},//SCALING_DCWCTR:DCW
{0x73, 0x00},//SCALING_PC[0000 XXXX]:DSP时钟分频
{0xa2, 0x02},//SCALING_PCLK_DELAY:像素时钟延迟
{0x11, 0x81},//CLKRC:时钟分频设置,0,不分频.
//伽马曲线参数
{0x7a, 0x20},//SLOP:
{0x7b, 0x1c},//GAM1
{0x7c, 0x28},//GAM2
{0x7d, 0x3c},//GAM3
{0x7e, 0x55},//GAM4
{0x7f, 0x68},//GAM5
{0x80, 0x76},//GAM6
{0x81, 0x80},//GAM7
{0x82, 0x88},//GAM8
{0x83, 0x8f},//GAM9
{0x84, 0x96},//GAM10
{0x85, 0xa3},//GAM11
{0x86, 0xaf},//GAM12
{0x87, 0xc4},//GAM13
{0x88, 0xd7},//GAM14
{0x89, 0xe8},//GAM15
{0x13, 0xe0},//COM8:AGC,AEC,条纹滤波器
{0x00, 0x00},//AGC
{0x10, 0x00},//AECH:曝光值
{0x0d, 0x00},//COM4[00XX 0000]:平均选择
{0x14, 0x28},//0x38, limit the max gain
{0xa5, 0x05},//BD50MAX:50Hz条纹滤波器步长限制
{0xab, 0x07},//BD60MAX:60Hz条纹滤波器步长限制
{0x24, 0x75},//AEW:40
{0x25, 0x63},//AEW:
{0x26, 0xA5},//VPT
//基于直方图的AEC/AGC控制
{0x9f, 0x78},//HAECC1
{0xa0, 0x68},//HAECC2
{0xa6, 0xdf},//HAECC3
{0xa7, 0xdf},//HAECC4
{0xa8, 0xf0},//HAECC5
{0xa9, 0x90},//HAECC6
{0xaa, 0x94},//HAECC7
{0x13, 0xe5},//COM8 【为何配置两次】
{0x0e, 0x61},//COM5 【保留】
{0x0f, 0x4b},//COM6
//{0x16, 0x02},//【保留】
{0x1e, 0x07},//MVFP:图像输出镜像控制.0x07,【镜像】
//{0x21, 0x02},//ADCCTR1:【保留】
//{0x22, 0x01},//ADCCTR1:【保留】
//{0x23, 0x00},//ADCCTR1:【保留】
//{0x33, 0x0b},//CHLF:【保留】
{0x37, 0x1d},//ADC:【保留】
{0x38, 0x71},//ACOM:【保留】
{0x39, 0x2a},//OFON:【保留】
{0x3c, 0x78},//COM12[X000 0000]:HREF选项
{0x69, 0x00},//GFIX:修复增益控制
{0x6b, 0x40},//DBLV:PLL*4=48Mhz
{0x74, 0x19},//REG74:
{0x92, 0x00},//DM_LNL:空行
{0x93, 0x00},//DM_LNH:空行
{0xb1, 0x0c},//ABLC1:自动黑电平校正使能
{0xb3, 0x82},//THL_ST:80
{0x43, 0x14},//AWBC1:【保留】
{0x44, 0xf0},//AWBC2:【保留】
{0x45, 0x34},//AWBC3:【保留】
{0x46, 0x58},//AWBC4:【保留】
{0x47, 0x28},//AWBC5:【保留】
{0x48, 0x3a},//AWBC6:【保留】
{0x64, 0x04},//LCC3:
{0x65, 0x20},//LCC4:
{0x66, 0x05},//LCC5:
{0x94, 0x04},//LCC6
{0x95, 0x08},//LCC7
{0x6c, 0x0a},//AWBCTR3
{0x6d, 0x55},//AWBCTR2
{0x6e, 0x11},//AWBCTR1
{0x6f, 0x9f},//AWBCTR0:0x9e for advance AWB
{0x4f, 0x80},//MTX1:
{0x50, 0x80},//MTX2:
{0x51, 0x00},//MTX3:
{0x52, 0x22},//MTX4:
{0x53, 0x5e},//MTX5:
{0x54, 0x80},//MTX6:
{0x09, 0x03},//COM2:驱动能力最大
{0x55, 0x00},//BRIGHT:亮度,原为00
{0x56, 0x40},//CONTRAS:对比度
{0x57, 0x80},//CONTRAS-CENTER:0x40, change according to Jim's request
读出的数据,方括号内为数据的字节统计
BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 [30]
BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 BD D7 [58]
BD 52 B4 F1
B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 [88]+4
B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 [118]
B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 B5 48 [134]
47 07 26 03
25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 [164]+8
25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 [194]
25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 25 74 [214]
2C CF 1C 8E
1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 [244]+12
1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 [274]
1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 1D 05 [290]
BA 66 A1 A3
98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 [320]+16
98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 [350]
98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 98 D1 [370]
A0 4D 90 0B
90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 [400]+20
90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 [430]
90 63 90 63 90 63 90 63 90 63 90 63 90 63 90 63 [446]
22 02 00 E0
00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E [476]+24
00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E [506]
00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E 00 6E [522]
08 0A 00 08
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [552]+28
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [582]
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [598]
08 20 94 51 +32=630
BD D7 BD D7 BD D7 BD D7 BD D7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [???]这是下一行数据了吧?
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
读取摄像头数据的代码{//读取一帧画面
V_XCLK_OFF();
//等待进入帧同步中断
do{
V_XCLK_L;
V_XCLK_H;
}
while(!GPIO_ReadInputDataBit(V_CONTROL,V_SYNC_Pin)); //捕获场同步的高电平
do{
V_XCLK_L;
V_XCLK_H;
}
while(GPIO_ReadInputDataBit(V_CONTROL,V_SYNC_Pin)); //捕获场同步的高电平
Task_Flag |= 0x08;
Task_Flag |= 0x04;
Herf_Counter = 0;
Current_Buf = V_Buf1;
for(;Herf_Counter<=240;)
{
do {
V_XCLK_H;
V_XCLK_L;
}
while(!GPIO_ReadInputDataBit(V_CONTROL,V_HERF_Pin)); //捕获到行同步
Point_Counter =0;
Herf_Counter += 1; //
Point_Counter = 0;
*Current_Buf = (u8) (Herf_Counter>>8); //DDêy¸3Öμ
*(Current_Buf+1) = (u8) Herf_Counter;
while(Point_Counter<640)
{
V_XCLK_H;
*(Current_Buf+2+Point_Counter++) = OV7670_Data_Cap();
V_XCLK_L;
}
OV7670_Data_Send(Current_Buf); //每采集完一行的数据后就发送,然后
}
return 0;
}
|
|