中级会员
- 积分
- 290
- 威望
- 176
- 贡献
- 56
- 兑换币
- 6
- 注册时间
- 2012-4-13
- 在线时间
- 29 小时
- 毕业学校
- 滨州学院
|
各位大侠,我的ov7620摄像头始终采集不到数据,求解释,已经两个礼拜了,下面是我用5110液晶调摄像头的程序,只是简单的采集数据程序,帮看一下,谢谢啊
#include <hidef.h> /* common defines and macros */
#include <MC9S12XS128.h> /* derivative-specific definitions */
#pragma LINK_INFO DERIVATIVE "mc9s12xs128"
#define SCE PORTB_PB0 //复位
#define RST PORTB_PB1 //使能
#define DC PORTB_PB2 //数据/命令选择
#define SDIN PORTB_PB3 //数据
#define SCLK PORTB_PB4 //时钟
unsigned int hang_count=0,lie_count=0;
unsigned int hangnum=0;
unsigned char jishu[65][100];
#define hang_end 240
#define lie_end 60
unsigned char zimo[][6] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // sp
{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, // !
{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, // "
{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // #
{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // $
{ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 }, // %
{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, // &
{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, // '
{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, // (
{ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, // )
{ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, // *
{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, // +
{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, // ,
{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, // -
{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, // .
{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, // /
{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0
{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1
{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2
{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3
{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4
{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5
{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 6
{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7
{ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8
{ 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E }, // 9
{ 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 }, // :
{ 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 }, // ;
{ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 }, // <
{ 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 }, // =
{ 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 }, // >
{ 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, // ?
{ 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, // @
{ 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, // A
{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B
{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C
{ 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D
{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E
{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F
{ 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G
{ 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H
{ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I
{ 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J
{ 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K
{ 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L
{ 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M
{ 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N
{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O
{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P
{ 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q
{ 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R
{ 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, // S
{ 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T
{ 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U
{ 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V
{ 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W
{ 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, // X
{ 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y
{ 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z
{ 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [
{ 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 }, // 55
{ 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ]
{ 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^
{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, // _
{ 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, // '
{ 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 }, // a
{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, // c
{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, // d
{ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 }, // e
{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f
{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, // g
{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h
{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i
{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, // j
{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k
{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l
{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m
{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, // o
{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, // p
{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, // q
{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r
{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, // s
{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t
{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u
{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v
{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w
{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, // x
{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, // y
{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, // z
{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 } // horiz lines
};
void delay_1ms(void)//1ms延时函数
{
unsigned int i;
for (i=0;i<30;i++);
}
void LCD_write_byte(uchar dt, uchar command)
{
uchar i;
SCE=0 ;
DC=command; //command=1为写数据,command=0为写指令
for(i=0;i<8;i++)
{
if(dt&0x80)
SDIN=1;
else
SDIN=0;
dt=dt<<1;
SCLK=0; //sclk上升沿接收一位数据
SCLK=1;
}
DC=1;
SCE =1;
SDIN=1;
}
/*---------------------------------------
LCD_init: 3310LCD初始化
编写日期:20080918
----------------------------------------- */
void LCD_init(void)
{
RST=0; //复位
delay_1ms();
RST=1;
LCD_write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令
LCD_write_byte(0xd0,0);//设定液晶偏置电压
LCD_write_byte(0x20,0);//使用基本指令
LCD_write_byte(0x0C,0);//设定显示模式,正常显示
}
/*-------------------------------------------
LCD_set_XY: 设置LCD坐标函数
输入参数:X:0-83 Y:0-5
编写日期:20080918
---------------------------------------------*/
void LCD_set_XY(uchar X, uchar Y)
{
LCD_write_byte(0x40 | Y, 0);// column 列
LCD_write_byte(0x80 | X, 0);// row 行
}
/*------------------------------------------
LCD_clear: LCD清屏函数
编写日期:20080918
--------------------------------------------*/
void LCD_clear(void)
{
uchar t;
uchar k;
LCD_set_XY(0,0);
for(t=0;t<6;t++)
{
for(k=0;k<84;k++)
{
LCD_write_byte(0x00,1);
}
}
}
void chaopin(void)
{
CLKSEL=0X00;
PLLCTL_PLLON=1; //超频后总线时钟64M
SYNR =0xc0 | 0x07;
REFDV=0xc0 | 0x01;
POSTDIV=0x00;
_asm(nop);
_asm(nop);
_asm(nop);
_asm(nop);
while(!(CRGFLG_LOCK==1));
CLKSEL_PLLSEL =1;
}
void TIM_init(void)
{
PACTL=0X50;
PACNT=0X0000;
TIOS =0x00;//定时器通道0,1 为输入捕捉
TSCR1=0x80;//定时器使能
TCTL4=0x18;//通道 1 捕捉下降沿通道 2 捕捉上升沿
TIE=0x06; //通道 1,2 中断使能
TFLG1=0xFF;//清中断标志位
}
void send_data(char weishu,int num)
{
int q,b,s,g,i;
q=(num/1000); //分离千位
num=num%1000;
b=(num/100); //分离百位
num=num%100;
s=(num/10); //分离十位
g=(num%10); //分离各位
//LCD_set_XY(0,0);
switch(weishu)
{
case 4: for(i=0;i<6;i++) LCD_write_byte(zimo[16+q][i],1);
case 3: for(i=0;i<6;i++) LCD_write_byte(zimo[16+b][i],1);
case 2: for(i=0;i<6;i++) LCD_write_byte(zimo[16+s][i],1);
case 1: for(i=0;i<6;i++) LCD_write_byte(zimo[16+g][i],1); break;
}
}
void main(void)
{
DDRB=0xFF;
DDRA=0xFF;
LCD_init();
LCD_clear();
chaopin();
TIM_init();
LCD_set_XY(8,0);
send_data(4,jishu[35][90]);
for(;;)
{
}
EnableInterrupts;
}
#pragma CODE_SEG NON_BANKED
void interrupt 10 IC2ISR(void) { //行中断 行同步接PT2 场同步接PT1 信号线是接A0
TFLG1_C2F=1;
//if(lie_count==get_n[c_lie]) { //定距采集图像的判断条件
// delay(1); //黑线中心矫正,确保不采集到消隐信号
for(lie_count=0;lie_count<=lie_end;lie_count++){ //读取一行的数据
jishu[lie_count][hangnum]=PORTA; //采集数据的接口
}
hangnum++; //二维数组行自加
}
void interrupt 9 IC1ISR(void){ //场中断,各数据清零
TFLG1_C1F=1;
hang_count=0;
lie_count=0;
}
#pragma CODE_SEG DEFAULT
|
|