专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
51单片机
OV7670_FIFO图像采集出来是斜线
2020-02-02 09:36
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
51单片机
2117
6
6
我用的是STC12C5A60S2,采集OV7670_FIFO图片(BMP格式)
寄存器配置应该是OK的。因为我用另外一个不带FIFO的OV7670采集出来是正常图像.
希望高手不啬赐教,谢谢了。
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
5条回答
redbaron
1楼-- · 2020-02-02 14:42
#include "STC_NEW_8051.h"
#include "sccb.h"
#include "delay.h"
#include <intrins.h>
#define WIDTH 320
#define HEIGHT 240
#define RELOAD_COUNT 0xfd //11.0592MHz,12T,SMOD=0,9600bps
//FIFO control lines
sbit FIFO_WR=P2^3;
sbit FIFO_WRST=P2^0;
sbit FIFO_RCK=P2^2;
sbit FIFO_RRST=P2^1;
sbit FIFO_OE=P2^4;
sbit FIFO_RE=P2^5;
sbit VSYNC = P0^3;
bit read_flag=0;
unsigned char ch;
unsigned char xdata pic[320];
void serial_port_one_initial()
{
SCON = 0x50; //0101,0000 8位可变波特率,无奇偶校验位
BRT = RELOAD_COUNT;
// BRTR = 1, S1BRS = 1, EXTRAM = 1 ENABLE EXTRAM
AUXR = 0x11; // T0x12,T1x12,UART_M0x6,BRTR,S2SMOD,BRTx12,EXTRAM,S1BRS
AUXR1 = 0x80;
ES = 1; //允许串口中断
EA = 1; //开总中断
}
void send_UART_one(unsigned char i)
{
ES = 0; //关串口中断
TI = 0; //清零串口发送完成中断请求标志
SBUF = i;
while(TI ==0); //等待发送完成
TI = 0; //清零串口发送完成中断请求标志
ES = 1; //允许串口中断
}
void main(void)
{
unsigned int i,j,k;
P2M1= 0xFF;
P2M0 =0x00;
P0M1 = 0x1C;
P0M0 = 0x00;
serial_port_one_initial();
sccb_senddata(0x12,0x80);
DelayMs(20);
sccb_senddata(0x11,0x1f); //sccb_senddata(0x11,0x03),设置成0x1f也完全OK;
sccb_senddata(0x3a, 0x04);
sccb_senddata(0x12, 0x11);
sccb_senddata(0x17, 0x16);
sccb_senddata(0x18, 0x04);
sccb_senddata(0x32, 0x80);
sccb_senddata(0x19, 0x02);
sccb_senddata(0x1a, 0x7a);
sccb_senddata(0x03, 0x0a);
sccb_senddata(0x0c, 0x00);
sccb_senddata(0x3e, 0x00);
sccb_senddata(0x70, 0x3a); //sccb_senddata(0x70, 0x3a);
sccb_senddata(0x71, 0x35); //sccb_senddata(0x71, 0x35); //sccb_senddata(0x71, 0x35);
sccb_senddata( 0x72, 0x11);
sccb_senddata( 0x73, 0xf0);
sccb_senddata( 0xa2, 0x02);
sccb_senddata(0x13, 0xe0);
sccb_senddata( 0x00, 0x00);
sccb_senddata( 0x10, 0x00);
sccb_senddata( 0x0d, 0x40);
sccb_senddata( 0x14, 0x38);
sccb_senddata( 0xa5 ,0x05);
sccb_senddata( 0xab, 0x07);
sccb_senddata( 0x24, 0x95);
sccb_senddata(0x25, 0x33);
sccb_senddata( 0x26, 0xe3);
sccb_senddata( 0x9f, 0x78);
sccb_senddata( 0xa0, 0x68);
sccb_senddata( 0xa1, 0x0b);
sccb_senddata(0xa6, 0xd8);
sccb_senddata(0xa7, 0xd8);
sccb_senddata(0xa8, 0xf0);
sccb_senddata(0xa9, 0x90);
sccb_senddata(0xaa, 0x94);
sccb_senddata(0x13, 0xe5);
sccb_senddata(0x0e, 0x61);
sccb_senddata(0x0f, 0x4b);
sccb_senddata(0x16, 0x02);
sccb_senddata(0x1e, 0x07 );
sccb_senddata(0x21, 0x02);
sccb_senddata(0x22, 0x91);
sccb_senddata(0x29, 0x07);
sccb_senddata(0x33, 0x0b);// ;03
sccb_senddata(0x35, 0x0b);
sccb_senddata(0x37, 0x1d);// ;1c
sccb_senddata(0x38, 0x71);
sccb_senddata(0x39, 0x2a);
sccb_senddata(0x3c, 0x78);
sccb_senddata(0x3d, 0x08);
sccb_senddata(0x41, 0x3a);
sccb_senddata(0x4d, 0x40);
sccb_senddata(0x4e, 0x20);
sccb_senddata(0x69, 0x00);// ;55
sccb_senddata(0x6b, 0x4a);
sccb_senddata(0x74, 0x19);
sccb_senddata(0x76, 0x61);
sccb_senddata(0x8d, 0x4f);
sccb_senddata(0x8e, 0x00);
sccb_senddata(0x8f, 0x00);
sccb_senddata(0x90, 0x00);
sccb_senddata(0x91, 0x00);
sccb_senddata(0x96,0x00);
sccb_senddata(0x9a, 0x80);
sccb_senddata(0xb0, 0x84 );//;8c
sccb_senddata(0xb1, 0x0c);
sccb_senddata(0xb2, 0x0e);
sccb_senddata(0xb3, 0x82);
sccb_senddata(0xb8, 0x0a);
sccb_senddata(0x43, 0x14);
sccb_senddata(0x44, 0xf0);
sccb_senddata(0x45, 0x34);
sccb_senddata(0x46, 0x58);
sccb_senddata(0x47, 0x28);
sccb_senddata(0x48, 0x3a);
sccb_senddata(0x59, 0x88);
sccb_senddata(0x5a, 0x88);
sccb_senddata(0x5b, 0x44);
sccb_senddata(0x5c, 0x67);
sccb_senddata(0x5d, 0x49);
sccb_senddata(0x5e, 0x0e);
sccb_senddata(0x6c, 0x0a);
sccb_senddata(0x6d, 0x55);
sccb_senddata(0x6e, 0x11);
sccb_senddata(0x6f, 0x9f);
sccb_senddata(0x6a, 0x40);
sccb_senddata(0x01, 0x40);
sccb_senddata(0x02, 0x40);
sccb_senddata(0x13, 0xe7);
sccb_senddata(0x34, 0x11);
sccb_senddata(0x3b,0x02);
sccb_senddata(0xa4, 0x88);
sccb_senddata(0x96 ,0x00);
sccb_senddata(0x97, 0x30);
sccb_senddata(0x98, 0x20);
sccb_senddata(0x99, 0x20);
sccb_senddata(0x9a, 0x84);
sccb_senddata(0x9b, 0x29);
sccb_senddata(0x9c, 0x03);
sccb_senddata(0x9d, 0x4c);
sccb_senddata(0x9e, 0x3f);
sccb_senddata(0x78, 0x04);
sccb_senddata(0x79, 0x01);
sccb_senddata(0xc8, 0xf0);
sccb_senddata(0x79, 0x0f);
sccb_senddata(0xc8, 0x00 );//;20
sccb_senddata(0x79, 0x10);
sccb_senddata(0xc8, 0x7e);
sccb_senddata(0x79, 0x0a);
sccb_senddata(0xc8, 0x80);
sccb_senddata(0x79, 0x0b);
sccb_senddata(0xc8, 0x01);
sccb_senddata(0x79, 0x0c);
sccb_senddata(0xc8, 0x0f);// ;07
sccb_senddata(0x79, 0x0d);
sccb_senddata(0xc8, 0x20);
sccb_senddata(0x79, 0x09);
sccb_senddata(0xc8, 0x80);
sccb_senddata(0x79, 0x02);
sccb_senddata(0xc8, 0xc0);
sccb_senddata(0x79, 0x03);
sccb_senddata(0xc8, 0x40);
sccb_senddata(0x79, 0x05);
sccb_senddata(0xc8, 0x30);
sccb_senddata(0x79, 0x26);
while(1)
{
if(read_flag==1)
{
read_flag=0;
if(ch=='R')
{
EA = 0;
if(VSYNC)
{
FIFO_WRST=0;
DelayUs2x(5);
FIFO_WRST=1;
FIFO_WR=1;
}
while(!VSYNC);
FIFO_WR=0;
FIFO_RRST=0; //reset the read address
FIFO_RCK=0; //at least one RCK clock is needed to make sure
FIFO_RCK=1;
FIFO_RCK=0;
FIFO_RCK=1;
FIFO_RRST=1;
FIFO_OE=1;
FIFO_OE=0;
for(i = 0; i < 240; i ++) //QVGA format,240 lines;320dots every line
{
FIFO_RE=0;
for(j = 0; j <320; j ++)
{
FIFO_RCK=0;
pic[j]=P1;
FIFO_RCK=1;
}
FIFO_RE=1;
for(j = 0; j <320; j ++)
{
send_UART_one(pic[j]);
}
}
FIFO_OE=1;
FIFO_WR=0;
EA=1;
}
}
}
}
void UART_one_Interrupt_Receive(void) interrupt 4
{
if(RI)
{
RI = 0;
ch = SBUF;
read_flag=1;
}
else
{
TI = 0;
}
}
加载中...
devcang
2楼-- · 2020-02-02 19:14
专业对专业,容易解决
加载中...
redbaron
3楼-- · 2020-02-02 21:10
精彩回答 2 元偷偷看……
加载中...
error_dan
4楼-- · 2020-02-02 23:36
时序问题,纯猜的。
加载中...
redbaron
5楼-- · 2020-02-03 04:08
顶一顶,继续求高手指教。谢谢
加载中...
一周热门
更多
>
相关问题
【东软载波ESF0654 PDS开发板活动】开箱
1 个回答
东软载波ESF0654 PDS开发板外部中断
1 个回答
东软载波ESF0654 PDS开发板高级控制定时器AD16C4T
1 个回答
用串口调试助手为什么只能在hex模式接收发送而在文本模式不行
9 个回答
触摸芯片SC02B/SC04B在地砖灯的设计方案
1 个回答
东软载波ESF0654 PDS开发板串口USART0代码分享
1 个回答
普通32位单片机使用linux的应用代码
5 个回答
东软载波ESF0654 PDS开发板AT24C04的调试
9 个回答
相关文章
51单片机与蓝牙模块连接
0个评论
51单片机的硬件结构
0个评论
基于51单片机的无线遥控器制作
0个评论
51单片机 AD转换
0个评论
51单片机数码管递增显示
0个评论
如何实现对单片机寄存器的访问
0个评论
基于51单片机的指纹密码锁
0个评论
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
51单片机
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
#include "sccb.h"
#include "delay.h"
#include <intrins.h>
#define WIDTH 320
#define HEIGHT 240
#define RELOAD_COUNT 0xfd //11.0592MHz,12T,SMOD=0,9600bps
//FIFO control lines
sbit FIFO_WR=P2^3;
sbit FIFO_WRST=P2^0;
sbit FIFO_RCK=P2^2;
sbit FIFO_RRST=P2^1;
sbit FIFO_OE=P2^4;
sbit FIFO_RE=P2^5;
sbit VSYNC = P0^3;
bit read_flag=0;
unsigned char ch;
unsigned char xdata pic[320];
void serial_port_one_initial()
{
SCON = 0x50; //0101,0000 8位可变波特率,无奇偶校验位
BRT = RELOAD_COUNT;
// BRTR = 1, S1BRS = 1, EXTRAM = 1 ENABLE EXTRAM
AUXR = 0x11; // T0x12,T1x12,UART_M0x6,BRTR,S2SMOD,BRTx12,EXTRAM,S1BRS
AUXR1 = 0x80;
ES = 1; //允许串口中断
EA = 1; //开总中断
}
void send_UART_one(unsigned char i)
{
ES = 0; //关串口中断
TI = 0; //清零串口发送完成中断请求标志
SBUF = i;
while(TI ==0); //等待发送完成
TI = 0; //清零串口发送完成中断请求标志
ES = 1; //允许串口中断
}
void main(void)
{
unsigned int i,j,k;
P2M1= 0xFF;
P2M0 =0x00;
P0M1 = 0x1C;
P0M0 = 0x00;
serial_port_one_initial();
sccb_senddata(0x12,0x80);
DelayMs(20);
sccb_senddata(0x11,0x1f); //sccb_senddata(0x11,0x03),设置成0x1f也完全OK;
sccb_senddata(0x3a, 0x04);
sccb_senddata(0x12, 0x11);
sccb_senddata(0x17, 0x16);
sccb_senddata(0x18, 0x04);
sccb_senddata(0x32, 0x80);
sccb_senddata(0x19, 0x02);
sccb_senddata(0x1a, 0x7a);
sccb_senddata(0x03, 0x0a);
sccb_senddata(0x0c, 0x00);
sccb_senddata(0x3e, 0x00);
sccb_senddata(0x70, 0x3a); //sccb_senddata(0x70, 0x3a);
sccb_senddata(0x71, 0x35); //sccb_senddata(0x71, 0x35); //sccb_senddata(0x71, 0x35);
sccb_senddata( 0x72, 0x11);
sccb_senddata( 0x73, 0xf0);
sccb_senddata( 0xa2, 0x02);
sccb_senddata(0x13, 0xe0);
sccb_senddata( 0x00, 0x00);
sccb_senddata( 0x10, 0x00);
sccb_senddata( 0x0d, 0x40);
sccb_senddata( 0x14, 0x38);
sccb_senddata( 0xa5 ,0x05);
sccb_senddata( 0xab, 0x07);
sccb_senddata( 0x24, 0x95);
sccb_senddata(0x25, 0x33);
sccb_senddata( 0x26, 0xe3);
sccb_senddata( 0x9f, 0x78);
sccb_senddata( 0xa0, 0x68);
sccb_senddata( 0xa1, 0x0b);
sccb_senddata(0xa6, 0xd8);
sccb_senddata(0xa7, 0xd8);
sccb_senddata(0xa8, 0xf0);
sccb_senddata(0xa9, 0x90);
sccb_senddata(0xaa, 0x94);
sccb_senddata(0x13, 0xe5);
sccb_senddata(0x0e, 0x61);
sccb_senddata(0x0f, 0x4b);
sccb_senddata(0x16, 0x02);
sccb_senddata(0x1e, 0x07 );
sccb_senddata(0x21, 0x02);
sccb_senddata(0x22, 0x91);
sccb_senddata(0x29, 0x07);
sccb_senddata(0x33, 0x0b);// ;03
sccb_senddata(0x35, 0x0b);
sccb_senddata(0x37, 0x1d);// ;1c
sccb_senddata(0x38, 0x71);
sccb_senddata(0x39, 0x2a);
sccb_senddata(0x3c, 0x78);
sccb_senddata(0x3d, 0x08);
sccb_senddata(0x41, 0x3a);
sccb_senddata(0x4d, 0x40);
sccb_senddata(0x4e, 0x20);
sccb_senddata(0x69, 0x00);// ;55
sccb_senddata(0x6b, 0x4a);
sccb_senddata(0x74, 0x19);
sccb_senddata(0x76, 0x61);
sccb_senddata(0x8d, 0x4f);
sccb_senddata(0x8e, 0x00);
sccb_senddata(0x8f, 0x00);
sccb_senddata(0x90, 0x00);
sccb_senddata(0x91, 0x00);
sccb_senddata(0x96,0x00);
sccb_senddata(0x9a, 0x80);
sccb_senddata(0xb0, 0x84 );//;8c
sccb_senddata(0xb1, 0x0c);
sccb_senddata(0xb2, 0x0e);
sccb_senddata(0xb3, 0x82);
sccb_senddata(0xb8, 0x0a);
sccb_senddata(0x43, 0x14);
sccb_senddata(0x44, 0xf0);
sccb_senddata(0x45, 0x34);
sccb_senddata(0x46, 0x58);
sccb_senddata(0x47, 0x28);
sccb_senddata(0x48, 0x3a);
sccb_senddata(0x59, 0x88);
sccb_senddata(0x5a, 0x88);
sccb_senddata(0x5b, 0x44);
sccb_senddata(0x5c, 0x67);
sccb_senddata(0x5d, 0x49);
sccb_senddata(0x5e, 0x0e);
sccb_senddata(0x6c, 0x0a);
sccb_senddata(0x6d, 0x55);
sccb_senddata(0x6e, 0x11);
sccb_senddata(0x6f, 0x9f);
sccb_senddata(0x6a, 0x40);
sccb_senddata(0x01, 0x40);
sccb_senddata(0x02, 0x40);
sccb_senddata(0x13, 0xe7);
sccb_senddata(0x34, 0x11);
sccb_senddata(0x3b,0x02);
sccb_senddata(0xa4, 0x88);
sccb_senddata(0x96 ,0x00);
sccb_senddata(0x97, 0x30);
sccb_senddata(0x98, 0x20);
sccb_senddata(0x99, 0x20);
sccb_senddata(0x9a, 0x84);
sccb_senddata(0x9b, 0x29);
sccb_senddata(0x9c, 0x03);
sccb_senddata(0x9d, 0x4c);
sccb_senddata(0x9e, 0x3f);
sccb_senddata(0x78, 0x04);
sccb_senddata(0x79, 0x01);
sccb_senddata(0xc8, 0xf0);
sccb_senddata(0x79, 0x0f);
sccb_senddata(0xc8, 0x00 );//;20
sccb_senddata(0x79, 0x10);
sccb_senddata(0xc8, 0x7e);
sccb_senddata(0x79, 0x0a);
sccb_senddata(0xc8, 0x80);
sccb_senddata(0x79, 0x0b);
sccb_senddata(0xc8, 0x01);
sccb_senddata(0x79, 0x0c);
sccb_senddata(0xc8, 0x0f);// ;07
sccb_senddata(0x79, 0x0d);
sccb_senddata(0xc8, 0x20);
sccb_senddata(0x79, 0x09);
sccb_senddata(0xc8, 0x80);
sccb_senddata(0x79, 0x02);
sccb_senddata(0xc8, 0xc0);
sccb_senddata(0x79, 0x03);
sccb_senddata(0xc8, 0x40);
sccb_senddata(0x79, 0x05);
sccb_senddata(0xc8, 0x30);
sccb_senddata(0x79, 0x26);
while(1)
{
if(read_flag==1)
{
read_flag=0;
if(ch=='R')
{
EA = 0;
if(VSYNC)
{
FIFO_WRST=0;
DelayUs2x(5);
FIFO_WRST=1;
FIFO_WR=1;
}
while(!VSYNC);
FIFO_WR=0;
FIFO_RRST=0; //reset the read address
FIFO_RCK=0; //at least one RCK clock is needed to make sure
FIFO_RCK=1;
FIFO_RCK=0;
FIFO_RCK=1;
FIFO_RRST=1;
FIFO_OE=1;
FIFO_OE=0;
for(i = 0; i < 240; i ++) //QVGA format,240 lines;320dots every line
{
FIFO_RE=0;
for(j = 0; j <320; j ++)
{
FIFO_RCK=0;
pic[j]=P1;
FIFO_RCK=1;
}
FIFO_RE=1;
for(j = 0; j <320; j ++)
{
send_UART_one(pic[j]);
}
}
FIFO_OE=1;
FIFO_WR=0;
EA=1;
}
}
}
}
void UART_one_Interrupt_Receive(void) interrupt 4
{
if(RI)
{
RI = 0;
ch = SBUF;
read_flag=1;
}
else
{
TI = 0;
}
}
一周热门 更多>