redbaron 发表于 2012-10-26 09:28:57

OV7670_FIFO图像采集出来是斜线

我用的是STC12C5A60S2,采集OV7670_FIFO图片(BMP格式)
寄存器配置应该是OK的。因为我用另外一个不带FIFO的OV7670采集出来是正常图像.

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

redbaron 发表于 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_COUNT0xfd   //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;


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=P1;
                               
                                        FIFO_RCK=1;       
                                       
                                       
                                  }
                              FIFO_RE=1;
                              for(j = 0; j <320; j ++)
                              {
                                send_UART_one(pic);
                              }
                          }
                       
                      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 发表于 2012-10-26 12:24:00

专业对专业,容易解决

redbaron 发表于 2012-10-26 13:51:34

请问:高手何解。本人愚钝。
是不是有专门的 摄像头板块,不过我找不到啊。
请指点啊,谢谢

error_dan 发表于 2012-10-26 13:54:38

时序问题,纯猜的。

redbaron 发表于 2012-10-29 14:59:03

顶一顶,继续求高手指教。谢谢
页: [1]
查看完整版本: OV7670_FIFO图像采集出来是斜线