搜索
bottom↓
回复: 5

OV7670_FIFO图像采集出来是斜线

[复制链接]

出0入0汤圆

发表于 2012-10-26 09:28:57 | 显示全部楼层 |阅读模式
我用的是STC12C5A60S2,采集OV7670_FIFO图片(BMP格式)
寄存器配置应该是OK的。因为我用另外一个不带FIFO的OV7670采集出来是正常图像.

希望高手不啬赐教,谢谢了。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

 楼主| 发表于 2012-10-26 09:42:43 | 显示全部楼层
#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;
    }
}


出0入0汤圆

发表于 2012-10-26 12:24:00 | 显示全部楼层
专业对专业,容易解决

出0入0汤圆

 楼主| 发表于 2012-10-26 13:51:34 | 显示全部楼层
请问:高手何解。本人愚钝。
是不是有专门的 摄像头板块,不过我找不到啊。
请指点啊,谢谢

出0入0汤圆

发表于 2012-10-26 13:54:38 | 显示全部楼层
时序问题,纯猜的。

出0入0汤圆

 楼主| 发表于 2012-10-29 14:59:03 | 显示全部楼层
顶一顶,继续求高手指教。谢谢
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-26 14:20

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表