注册会员
- 积分
- 127
- 威望
- 175
- 贡献
- 22
- 兑换币
- 0
- 注册时间
- 2008-5-18
- 在线时间
- 0 小时
|
<>小弟第一次参加这个比赛,一组的同伴也是一样,都没有经验,老师整天忙他的项目,也不来管我们,不过问了也不知道就是。。。</P><P>动作比较慢,还在搞AD采样部分</P><P>选用的是CMOS黑白摄像头,摄像头视频线接1881 引脚2,行同步接PT3, 场同步接PT1,利用中断采集信号</P><P>利用串口调试助手将AD转化后的值 直接发送至PC上显示</P><P>应该是程序出问题了,无论对着什么地方照,输出的16进制AD转化的值总是有斜线产生(没有将AD值进行2值化比较,总是每隔几个点就会输出00,0E什么的,如果进行2值化,能更明显的看到许多条从右上往左下方的斜线。。。</P><P>超不超频都有这样的情况产生(用示波器看摄像头输出的视频信号是非常好的,根本没有这种干扰</P><P> </P><P>下面是同学利用PE编写的程序,麻烦哪位大人帮忙找找看问题吧(我们这组都是学机械的,对电还有程序这一块几乎完全不擅长Orz。。。</P><P>void ini_sci(void) {<BR> <BR> SCI0BD= 0x9C; // 波特率设为9600,与串口调试助手相同<BR> SCI0CR1=0X00;<BR> SCI0CR2=0X0C;<BR> }<BR> void AD_Init(void) <BR>{ <BR> ATD0CTL2 = 0xC0; //AD上电 快速标志位清零顺序 每次读取结果寄存器自动清零<BR> ATD0CTL3 = 0x08; //转换序列为1 <BR> ATD0CTL4 = 0x85; //8位精度 预分频为6 采样时间为2个A/D时钟周期 2M<BR> ATD0CTL5 = 0xa0; //右对齐 <BR> ATD0DIEN=0x00;<BR> <BR> }<BR> </P><P>void main(void)<BR>{<BR> ini_sci();<BR> AD_Init();<BR> /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/<BR> PE_low_level_init();<BR> /*** End of Processor Expert internal initialization. ***/</P><P> PWME_PWME5=0x01;<BR> EnableInterrupts;<BR> <BR> /* please make sure that you never leave this function */<BR> <BR> /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/<BR> for(;;){}<BR>}</P><P> </P><P>==========上面是初始化还有一些什么的,下面是终端程序============================================</P><P><BR>#include "Cpu.h"<BR>#include "Events.h"</P><P>#pragma CODE_SEG DEFAULT<BR>#define EnableInterrupts {__asm CLI;}<BR>/*<BR>** ===================================================================<BR>** Event : Cap1_OnCapture (module Events)<BR>**<BR>** From bean : Cap1 [Capture]<BR>** Description :<BR>** This event is called on capturing of Timer/Counter actual<BR>** value (only when the bean is enabled - <"Enable"> and the<BR>** events are enabled - <"EnableEvent">.<BR>** Parameters : None<BR>** Returns : Nothing<BR>** ===================================================================<BR>*/ </P><P>int ccd_data[8];<BR>int ccd_data1[24][8];<BR>int i,r,m;</P><P><BR>int row_num=0;<BR>int row_10;</P><P> </P><P> </P><P> void tx_sci(int tx_d)<BR> {<BR> while(SCI0SR1_TC!=1); <BR> while(SCI0SR1_TDRE!=1);<BR> SCI0DRL=(byte)tx_d; <BR>}</P><P> </P><P> <BR>/*<BR>** ===================================================================<BR>** Event : AD1_OnEnd (module Events)<BR>**<BR>** From bean : AD1 [ADC]<BR>** Description :<BR>** This event is called after the measurement (which<BR>** consists of <1 or more conversions>) is/are finished.<BR>** Parameters : None<BR>** Returns : Nothing<BR>** ===================================================================<BR>*/</P><P>/*<BR>** ===================================================================<BR>** Event : Cap2_OnCapture (module Events)<BR>**<BR>** From bean : Cap2 [Capture]<BR>** Description :<BR>** This event is called on capturing of Timer/Counter actual<BR>** value (only when the bean is enabled - <"Enable"> and the<BR>** events are enabled - <"EnableEvent">.<BR>** Parameters : None<BR>** Returns : Nothing<BR>** ===================================================================<BR>*/<BR>void Cap2_OnCapture(void)<BR>{ <BR> <BR> //场同步信号,场中断接pt1 </P><P> row_num=0; //行记数器清零<BR> <BR> tx_sci(0x42); // 场中断来临后向串口发送42,以表示换场<BR> <BR> TIE_C1I=0X00;<BR> TIE_C3I=0X01; //关场中断,打开行中断<BR> <BR> <BR> /* Write your code here ... */<BR>}</P><P>/*<BR>** ===================================================================<BR>** Event : Cap4_OnCapture (module Events)<BR>**<BR>** From bean : Cap4 [Capture]<BR>** Description :<BR>** This event is called on capturing of Timer/Counter actual<BR>** value (only when the bean is enabled - <"Enable"> and the<BR>** events are enabled - <"EnableEvent">.<BR>** Parameters : None<BR>** Returns : Nothing<BR>** ===================================================================<BR>*/<BR>void Cap4_OnCapture(void)<BR>{ //行同步信号,行中断接pt3<BR> </P><P> <BR> row_num++;<BR> <BR> <BR> if(row_num>=30&&row_num<=260)<BR> { row_10=row_num%10;<BR> if(row_10==0)<BR> { r=row_num-30;<BR> r=r/10;<BR> <BR> <BR> <BR> <BR> for(i=0;i<8;i++) //时钟没有超频,2M转换速度,每次转换采8个点<BR> {<BR> while(!ATD0STAT1_CCF0);<BR> <BR> m=(byte)ATD0DR0L; //AD转换后的值直接发送至m,然后输出到串口<BR> <BR> // if(m>0x30) m=0; <BR> // else m=1; <BR> tx_sci(m);<BR> ccd_data<i>=m;<BR> ccd_data1[r]<i>=m;<BR> }<BR> <BR> tx_sci(0x41); //每换一行向串口发送41,表示换行<BR> <BR> <BR> }<BR> }<BR> if(row_num>260)<BR> <BR> {<BR> TIE_C3I=0X00;<BR> TIE_C1I=0X01; //开场中断,关行中断<BR> }</P><P> /* Write your code here ... */<BR>}</P><P>/*<BR>** ===================================================================<BR>** Event : AD1_OnEnd (module Events)<BR>**<BR>** From bean : AD1 [ADC]<BR>** Description :<BR>** This event is called after the measurement (which<BR>** consists of <1 or more conversions>) is/are finished.<BR>** Parameters : None<BR>** Returns : Nothing<BR>** ===================================================================<BR>*/<BR>void AD1_OnEnd(void)<BR>{<BR> /* Write your code here ... */<BR>}</P><P> </P><P> </P><P>以上,感谢大家先了。。。<BR></P> |
|