ov7670摄像头程序
ov7670摄像头程序.rar
(70.58 KB)
/******************************************************************************
接线说明:
WRST P1.0
WEN P1.1
RRST P1.2
OE P1.3
RCLK P1.4
SCCB_CLK P1.5
SCCB_DATA P1.6
VSYNC P1.7
D0 P4.0
D1 P4.1
D2 P4.2
D3 P4.3
D4 P4.4
D5 P4.5
D6 P4.6
D7 P4.7
LCD_CS P3.0
LCD_RS P3.1
LCD_WR P3.2
LCD_RD P3.3
LCD_RST P3.4
DB00 P5.0
DB01 P5.1
DB02 P5.2
DB03 P5.3
DB04 P5.4
DB05 P5.5
DB06 P5.6
DB07 P5.7
DB08 P6.0
DB09 P6.1
DB10 P6.2
DB11 P6.3
DB12 P6.4
DB13 P6.5
DB14 P6.6
DB15 P6.7
缺陷: 1.无法读ov7670REG.
2.启动时,第一帧图像花屏
******************************************************************************/
#include <msp430x14x.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
//#include "fifo.h"
#include "int.h"
#include "ov7670.h"
//#include "SCCB.h"
#include "TFT(8999).h"
extern uchar fifo_ready;
void OSCInit()//系统时钟初始化
{
unsigned int j;
BCSCTL1=0x00;
do
{
IFG1&=~OFIFG;
for(j=0x20;j>0;j--);
}
while((IFG1&OFIFG)==OFIFG);//判断时钟是否起震
BCSCTL2=0x00;
BCSCTL2=SELM_2+DIVM_0+SELS;//系统时钟选择
//主系统时钟DCO振荡器,1分频,子系统时钟高速晶体振荡器8M
}
void URATInit()
{
P3SEL|=BIT4+BIT5;
ME1|=UTXE0+URXE0;//URAT模块开启
UCTL0|=PENA+PEV+CHAR;//偶校验,8位
UTCTL0|=SSEL1;//sMCLK,32.768khz;115200
UBR00=0X45;
UBR10=0x00;
UMCTL0=0x2c;
UCTL0&=~SWRST;
// IE1|=URXIE0;//接收中断开启
}
void SendChar(uchar data)
{
while (!(IFG1 & UTXIFG0)) // USCI_A0 TX buffer ready?
{}
TXBUF0 = data;
}
void main()
{
// ulong i=0,j=0;
WDTCTL = WDTPW + WDTHOLD; //关狗
DCOCTL |= (DCO0 + DCO1 + DCO2); //内部晶振调大最大
BCSCTL1 |= (RSEL0 + RSEL1 + RSEL2);
P2DIR |= 0x01;
// URATInit();
OSCInit();
OV7670FIFO_init();
Lcd_Init(); //摄像头初始化
ClearScreen(0xf800);//清屏
show_colour_bar();//显示彩条
int_init();
_EINT();
TakePic();
while(1)
{
uchar x,y;
if(fifo_ready == 1)
{
PicProcess(&x , &y);
TakePic();
fifo_ready = 0;
}
}
}
|