智能车制作

 找回密码
 注册

扫一扫,访问微社区

查看: 1647|回复: 0
打印 上一主题 下一主题

[采集类] 求助

[复制链接]

4

主题

56

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
402
QQ
威望
297
贡献
47
兑换币
0
注册时间
2011-4-18
在线时间
29 小时
跳转到指定楼层
1#
发表于 2011-4-28 19:54:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1贡献
本人遇到摄像头采集上位机的问题,程序如下#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include <MC9S12XS128.h>

void SCI0_Transmit(void);
void IOC_Contrl(void);

byte ta[38][90];
byte Point_C, YSYN_C, Line_Flag, m = 0,n=0;
byte Line_C=0,c_lie=0;
unsigned char jiange;

//PLL初始化
void PLL_INC(void)
{
CLKSEL=0x00; //48mhz
SYNR=0XC0 | 0X05;
REFDV=0XC0 | 0X03;
PLLCTL_PLLON=1;
POSTDIV=0X00;
asm(nop);
asm(nop);
while(0==CRGFLG_LOCK); //锁相环锁定
CLKSEL_PLLSEL=1; //选定PLL时钟
}

/*-------串口初始化----------------------*/
void SCI0_Init()
{
SCI0BDL = (byte)((48000000 /* OSC freq *//2) / 57600 /* baud rate */ / 16 /*factor*/);
SCI0CR1 = 0X00; /*normal,no parity*/
SCI0CR2 = 0X0C; /*RIE=1,TE=1,RE=1, */
}

//输入捕捉初始化
void IOC_Init(void)
{
TIOS =0x00;//定时器通道0,1 为输入捕捉
TSCR1=0x80;//定时器使能
TCTL4=0x09;//通道0 捕捉上升沿通道1 捕捉下降沿
TIE=0x03; //通道0,1 中断使能
TFLG1=0xFF;//清中断标志位
}

//中断定义
#pragma CODE_SEG NON_BANKED

//IC1通道中断 场中断
interrupt 9 void VSYN_Interrupt(void)
{
TFLG1_C1F = 1; //清场中断
TFLG1_C0F = 1; //清行中断
Point_C = 0;
Line_C = 0; //行计数器
YSYN_C++;
SCI0DRL = 0X0A; //回车
while (!(SCI0SR1&0x80));
SCI0DRL = 0X0D;
while (!(SCI0SR1&0x80));
}

//IC0通道中断 行中断
interrupt 8 void HREF_Count(void)
{
TFLG1_C0F = 1;
Line_Flag = 0;
m++;
if ( m<12 || m>288 )
{
return;//判断是否从新的一场开始
}
if(m<=132)jiange=12;
else if(m>132&&m<=200) jiange=8;
else if(m>200&&m<=248) jiange=6;
else jiange=4;
if(m%jiange==0)

{
IOC_Contrl();
SCI0_Transmit();

Line_C++;
}
}

#pragma CODE_SEG DEFAULT

/*-------发射端程序----------------------*/
void SCI0_Transmit()
{
byte i, temp;
temp = SCI0SR1; //清零
SCI0DRH = 0;
for(i = 0;i < 90 ;i++)
{
if(ta[Line_C]>0 & ta[Line_C][i+1]>0)
SCI0DRL = 0x31;
else SCI0DRL = 0X30;

while (!(SCI0SR1&0x80)); /* wait for output buffer empty */
}
SCI0DRL = 0X0A; //回车
while (!(SCI0SR1&0x80));
SCI0DRL = 0X0D; //换行                     
while (!(SCI0SR1&0x80));
}

//计数控制
void IOC_Contrl(void)
{

    ta[c_lie][0]=PORTA_PA0;
    ta[c_lie][0]=PORTA_PA0;
    ta[c_lie][1]=PORTA_PA0;
    ta[c_lie][1]=PORTA_PA0;
    ta[c_lie][2]=PORTA_PA0;
    ta[c_lie][2]=PORTA_PA0;
    ta[c_lie][3]=PORTA_PA0;
    ta[c_lie][3]=PORTA_PA0;
    ta[c_lie][4]=PORTA_PA0;
    ta[c_lie][4]=PORTA_PA0;
    ta[c_lie][5]=PORTA_PA0;
    ta[c_lie][5]=PORTA_PA0;
    ta[c_lie][6]=PORTA_PA0;
    ta[c_lie][6]=PORTA_PA0;
    ta[c_lie][7]=PORTA_PA0;
    ta[c_lie][7]=PORTA_PA0;
    ta[c_lie][8]=PORTA_PA0;
    ta[c_lie][8]=PORTA_PA0;
    ta[c_lie][9]=PORTA_PA0;
    ta[c_lie][9]=PORTA_PA0;
    ta[c_lie][10]=PORTA_PA0;
    ta[c_lie][10]=PORTA_PA0;
    ta[c_lie][11]=PORTA_PA0;
    ta[c_lie][11]=PORTA_PA0;
    ta[c_lie][12]=PORTA_PA0;
    ta[c_lie][12]=PORTA_PA0;
    ta[c_lie][13]=PORTA_PA0;
    ta[c_lie][13]=PORTA_PA0;
    ta[c_lie][14]=PORTA_PA0;
    ta[c_lie][14]=PORTA_PA0;
    ta[c_lie][15]=PORTA_PA0;
    ta[c_lie][15]=PORTA_PA0;
    ta[c_lie][16]=PORTA_PA0;
    ta[c_lie][16]=PORTA_PA0;
    ta[c_lie][17]=PORTA_PA0;
    ta[c_lie][17]=PORTA_PA0;
    ta[c_lie][18]=PORTA_PA0;
    ta[c_lie][18]=PORTA_PA0;
    ta[c_lie][19]=PORTA_PA0;
    ta[c_lie][19]=PORTA_PA0;
    ta[c_lie][20]=PORTA_PA0;
    ta[c_lie][20]=PORTA_PA0;
    ta[c_lie][21]=PORTA_PA0;
    ta[c_lie][21]=PORTA_PA0;
    ta[c_lie][22]=PORTA_PA0;
    ta[c_lie][22]=PORTA_PA0;
    ta[c_lie][23]=PORTA_PA0;
    ta[c_lie][23]=PORTA_PA0;
    ta[c_lie][24]=PORTA_PA0;
    ta[c_lie][24]=PORTA_PA0;
    ta[c_lie][25]=PORTA_PA0;
    ta[c_lie][25]=PORTA_PA0;
    ta[c_lie][26]=PORTA_PA0;
    ta[c_lie][26]=PORTA_PA0;
    ta[c_lie][27]=PORTA_PA0;
    ta[c_lie][27]=PORTA_PA0;
    ta[c_lie][28]=PORTA_PA0;
    ta[c_lie][28]=PORTA_PA0;
    ta[c_lie][29]=PORTA_PA0;
    ta[c_lie][29]=PORTA_PA0;
    ta[c_lie][30]=PORTA_PA0;
    ta[c_lie][30]=PORTA_PA0;
    ta[c_lie][31]=PORTA_PA0;
    ta[c_lie][31]=PORTA_PA0;
    ta[c_lie][32]=PORTA_PA0;
    ta[c_lie][32]=PORTA_PA0;
    ta[c_lie][33]=PORTA_PA0;
    ta[c_lie][33]=PORTA_PA0;
    ta[c_lie][34]=PORTA_PA0;
    ta[c_lie][34]=PORTA_PA0;
    ta[c_lie][35]=PORTA_PA0;
    ta[c_lie][35]=PORTA_PA0;
    ta[c_lie][36]=PORTA_PA0;
    ta[c_lie][36]=PORTA_PA0;
    ta[c_lie][37]=PORTA_PA0;
    ta[c_lie][37]=PORTA_PA0;
    ta[c_lie][38]=PORTA_PA0;
    ta[c_lie][38]=PORTA_PA0;
    ta[c_lie][39]=PORTA_PA0;
    ta[c_lie][39]=PORTA_PA0;
    ta[c_lie][40]=PORTA_PA0;
    ta[c_lie][40]=PORTA_PA0;
    ta[c_lie][41]=PORTA_PA0;
    ta[c_lie][41]=PORTA_PA0;
    ta[c_lie][42]=PORTA_PA0;
    ta[c_lie][42]=PORTA_PA0;
    ta[c_lie][43]=PORTA_PA0;
    ta[c_lie][43]=PORTA_PA0;
    ta[c_lie][44]=PORTA_PA0;
    ta[c_lie][44]=PORTA_PA0;   
    ta[c_lie][45]=PORTA_PA0;
    ta[c_lie][45]=PORTA_PA0;
    ta[c_lie][46]=PORTA_PA0;
    ta[c_lie][46]=PORTA_PA0;
    ta[c_lie][47]=PORTA_PA0;
    ta[c_lie][47]=PORTA_PA0;
    ta[c_lie][48]=PORTA_PA0;
    ta[c_lie][48]=PORTA_PA0;
    ta[c_lie][49]=PORTA_PA0;
    ta[c_lie][49]=PORTA_PA0;
    ta[c_lie][50]=PORTA_PA0;
    ta[c_lie][50]=PORTA_PA0;
    ta[c_lie][51]=PORTA_PA0;
    ta[c_lie][51]=PORTA_PA0;
    ta[c_lie][52]=PORTA_PA0;
    ta[c_lie][52]=PORTA_PA0;
    ta[c_lie][53]=PORTA_PA0;
    ta[c_lie][53]=PORTA_PA0;
    ta[c_lie][54]=PORTA_PA0;
    ta[c_lie][54]=PORTA_PA0;
    ta[c_lie][55]=PORTA_PA0;
    ta[c_lie][55]=PORTA_PA0;
    ta[c_lie][56]=PORTA_PA0;
    ta[c_lie][56]=PORTA_PA0;
    ta[c_lie][57]=PORTA_PA0;
    ta[c_lie][57]=PORTA_PA0;
    ta[c_lie][58]=PORTA_PA0;
    ta[c_lie][58]=PORTA_PA0;
    ta[c_lie][59]=PORTA_PA0;
    ta[c_lie][59]=PORTA_PA0;
    ta[c_lie][60]=PORTA_PA0;
    ta[c_lie][60]=PORTA_PA0;
    ta[c_lie][61]=PORTA_PA0;
    ta[c_lie][61]=PORTA_PA0;
    ta[c_lie][62]=PORTA_PA0;
    ta[c_lie][62]=PORTA_PA0;
    ta[c_lie][63]=PORTA_PA0;
    ta[c_lie][63]=PORTA_PA0;
    ta[c_lie][64]=PORTA_PA0;
    ta[c_lie][64]=PORTA_PA0;
    ta[c_lie][65]=PORTA_PA0;
    ta[c_lie][65]=PORTA_PA0;
    ta[c_lie][66]=PORTA_PA0;
    ta[c_lie][66]=PORTA_PA0;
    ta[c_lie][67]=PORTA_PA0;
    ta[c_lie][67]=PORTA_PA0;
    ta[c_lie][68]=PORTA_PA0;
    ta[c_lie][68]=PORTA_PA0;
    ta[c_lie][69]=PORTA_PA0;
    ta[c_lie][69]=PORTA_PA0;
    ta[c_lie][70]=PORTA_PA0;
    ta[c_lie][70]=PORTA_PA0;
    ta[c_lie][71]=PORTA_PA0;
    ta[c_lie][71]=PORTA_PA0;
    ta[c_lie][72]=PORTA_PA0;
    ta[c_lie][72]=PORTA_PA0;
    ta[c_lie][73]=PORTA_PA0;
    ta[c_lie][73]=PORTA_PA0;
    ta[c_lie][74]=PORTA_PA0;
    ta[c_lie][74]=PORTA_PA0;
    ta[c_lie][75]=PORTA_PA0;
    ta[c_lie][75]=PORTA_PA0;
    ta[c_lie][76]=PORTA_PA0;
    ta[c_lie][76]=PORTA_PA0;
    ta[c_lie][77]=PORTA_PA0;
    ta[c_lie][77]=PORTA_PA0;
    ta[c_lie][78]=PORTA_PA0;
    ta[c_lie][78]=PORTA_PA0;
    ta[c_lie][79]=PORTA_PA0;
    ta[c_lie][79]=PORTA_PA0;
    ta[c_lie][80]=PORTA_PA0;
    ta[c_lie][80]=PORTA_PA0;
    ta[c_lie][81]=PORTA_PA0;
    ta[c_lie][81]=PORTA_PA0;
    ta[c_lie][82]=PORTA_PA0;
    ta[c_lie][82]=PORTA_PA0;
    ta[c_lie][83]=PORTA_PA0;
    ta[c_lie][83]=PORTA_PA0;
    ta[c_lie][84]=PORTA_PA0;
    ta[c_lie][84]=PORTA_PA0;
    ta[c_lie][85]=PORTA_PA0;
    ta[c_lie][85]=PORTA_PA0;
    ta[c_lie][86]=PORTA_PA0;
    ta[c_lie][86]=PORTA_PA0;
    ta[c_lie][87]=PORTA_PA0;
    ta[c_lie][87]=PORTA_PA0;
    ta[c_lie][88]=PORTA_PA0;
    ta[c_lie][88]=PORTA_PA0;
    ta[c_lie][89]=PORTA_PA0;
    ta[c_lie][89]=PORTA_PA0;
}

void main(void)
{
/* put your own code here */

DisableInterrupts;
DDRA = 0X00;
PLL_INC();

SCI0_Init();

IOC_Init();

EnableInterrupts;
for(;;)
{
_FEED_COP(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave main */
}

我用的是图像数字信号端接PA0,行中断接PT0,PT1接场中断,接线没错,不知道是不是程序有问题望能指教。
我直接把摄像头对着白色KT板出现的图像
不知道是不是摄像头不能用?望各位能人志士能帮帮忙。

附件: 您需要 登录 才可以下载或查看,没有帐号?注册
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关于我们|联系我们|小黑屋|智能车制作 ( 黑ICP备2022002344号

GMT+8, 2024-6-17 00:50 , Processed in 0.041400 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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