ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:18.18KB ,
资源ID:7697209      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7697209.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(摄像头 程序.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

摄像头 程序.docx

1、摄像头 程序最终还是没能赶上校内赛,虽然是很伤心,在这里只想现在的,以后的孩子不要再话那么多的时间在图像采集方面,可以放多点时间在数据处理方面,以免重蹈我们的悲剧,现在上传上位机程序,如果你喜欢,可以买个20块的上位机(淘宝有),这样就可以看到图像。(PS:绝对没有帮他们卖广告的嫌疑,只是想同学们可以早点搞好图像。)/T0接受行中断,上升沿触发,T1接受场中断,下降沿触发/数据口为PA0-PA7/波特率为115200/串口分别接单片机S0 S1/图像大小选择 60*30 /设置帧头帧尾为0x01#include /* common defines and macros */#include d

2、erivative.h /* derivative-specific definitions */#define uint unsigned int#define uchar unsigned charuchar hang_count;#define hangshu 30#define lieshu 100#define Mid 1365#define THRESHOLD 0x70unsigned char Dianji_data;unsigned int Duoji_data;unsigned int zuo_danxian=1,you_danxian=1;uint hang,lie,cen

3、terhangshu,lefthangshu,righthangshu,image_center;uchar row,line1,line2;uint steer;uchar shuzuhangshulieshu;uint hang_table=65,69,74,79,83,86,93,100, 107,114,121,128,135,142,145,149,152,156,160,163,166, 169,173,176,180,183,187,190,193,197,; byte count,second;void Delay(int De_a) int De_b; for(De_b=0;

4、De_bDe_a;De_b+) _asm(nop); / _asm(nop); /*/void crg_init(void) CLKSEL=0x00; / 脱离锁相环 PLLCTL_PLLON=1; / 打开锁相环 SYNR=0XC0 | 0X09; / SYNR =3,REFDV=1 REFDV=0X80 | 0X01; / pllclock=2*16*(1+SYNR)/(1+REFDV)=96MHz; POSTDIV=0X00; / 锁相环时钟为96MHz _asm(nop); _asm(nop); while(0=CRGFLG_LOCK); / 锁相环锁定 CLKSEL_PLLSEL=1

5、; void PWM_Init(void) PWME=0X00; /禁止通道PWMPRCLK=0X33; /A=B=80/8=10MHZPWMSCLA=5; /SA=A/2/5=1MHZPWMSCLB=5; /SB=B/2/5=1MHZ /*PWM 0,1级联初始化*/PWMCTL_CON01=1; /0,1级联,寄存器为通道1的PWMCLK_PCLK1=1; /选时钟SBPWMPOL_PPOL1=1; /初始电平为高PWMCAE_CAE1=0; /左对齐方式PWMCNT01=0; /计数器清零PWMPER01=20000; /输出周期=SB/10000=100HZPWMDTY01=1580;

6、 /舵机静止占空比为7.5%=1500/20000PWME_PWME1=1; /使能PWMCTL_CON23=1;PWMCLK_PCLK3=0;PWMPOL_PPOL3=1; PWMCAE_CAE3=0;PWMCNT23=0;PWMPER23=600;PWMDTY23=0;PWME_PWME3=1; PWMCTL_CON45=1;PWMCLK_PCLK5=0;PWMPOL_PPOL5=1; PWMCAE_CAE5=0;PWMCNT45=0; PWMPER45=0;PWMDTY45=500; PWME_PWME5=1; /*舵机控制*/void PWMDuo_Dutycycle(int a) P

7、WMDTY01=a;void PWMDian_Dutycycle(int b) PWMDTY45=b; /* - 功能描述:T0接受行中断,上升沿触发,T1接受场中断,下降沿触发,T7计数- 参数说明:- 返回说明: - 修改记录:- 注意事项:总线时钟为40M时,该程序适用。*/void ect_init()TIOS=0x00; /T0、T1设置为输入捕捉,摄像头行场中断-关输出比较通道7TCTL4=0x09; /通道0为上升沿捕捉,1为下降沿捕捉TIE=0x03; /开场中断,行中断TSCR1=0x80; /定时器正常工作TSCR2=0x00; /最后三位为预分频因子选择位TFLG1=0x

8、FF; /清除该位TFLG2=0x80; /清除 TOF /*/ IO初始化子函数/*/ void IO_init(void) / IO初始化函数 DDRA = 0X00; void photo()unsigned char i,j;for(i=0;i=29;i+) for(j=0;j=65;j+) if(shuzuj发送移位寄存器中 while (!SCI0SR1_TC); / 等待发送移位寄存器中的数值发送完成 SCI0DRL = data; /* - 功能描述:SCI发送一个字符串 - 参数说明:- 返回说明: - 修改记录:- 注意事项:*/ void SCI_Send_Uchar_S

9、tring(unsigned char *putchar, uint num) uint counter = 0; while (counter+) num) / 判断字符串是否发送完毕 SCI_Send_Byte(*(putchar+); void SCI_Send_Image_String(unsigned char *putchar, uint num) uint counter = 0; for(counter=0;counternum;counter+) if(putcharcounter=0x01) putcharcounter=0x02; SCI_Send_Byte(putcha

10、rcounter); void main(void) /* put your own code here */ /* uchar x,data; */ crg_init(); ect_init(); IO_init() ; Init_SCI(); PWM_Init();EnableInterrupts; for(;) _FEED_COP(); /* feeds the dog */ /* loop forever */ /* please make sure that you never leave main */* 功能描述:行中断服务程序,接PT0参数说明:返回说明: 修改记录:注意事项:

11、*/#pragma CODE_SEG NON_BANKEDvoid interrupt 8 Port0_Interrupt() int i=0,j=0; unsigned char *p; TFLG1=0x01; hang+; /行计数器加 1 if (hang240) return;/判断是否从新的一场开始 if(hang=hang_tablehang_count)/行数组采样变量 Delay(1); p=&shuzuhang_count0; shuzuhang_count0=PORTA;_asm();shuzuhang_count1=PORTA;_asm();shuzuhang_count

12、2=PORTA;_asm();shuzuhang_count3=PORTA;_asm();shuzuhang_count4=PORTA;_asm(); shuzuhang_count5=PORTA;_asm();shuzuhang_count6=PORTA;_asm();shuzuhang_count7=PORTA;_asm();shuzuhang_count8=PORTA;_asm();shuzuhang_count9=PORTA;_asm(); shuzuhang_count10=PORTA;_asm();shuzuhang_count11=PORTA;_asm();shuzuhang_c

13、ount12=PORTA;_asm();shuzuhang_count13=PORTA;_asm();shuzuhang_count14=PORTA;_asm(); shuzuhang_count15=PORTA;_asm();shuzuhang_count16=PORTA;_asm();shuzuhang_count17=PORTA;_asm();shuzuhang_count18=PORTA;_asm();shuzuhang_count19=PORTA;_asm(); shuzuhang_count20=PORTA;_asm();shuzuhang_count21=PORTA;_asm()

14、;shuzuhang_count22=PORTA;_asm();shuzuhang_count23=PORTA;_asm();shuzuhang_count24=PORTA;_asm(); shuzuhang_count25=PORTA;_asm();shuzuhang_count26=PORTA;_asm();shuzuhang_count27=PORTA;_asm();shuzuhang_count28=PORTA;_asm();shuzuhang_count29=PORTA;_asm(); shuzuhang_count30=PORTA;_asm();shuzuhang_count31=

15、PORTA;_asm();shuzuhang_count32=PORTA;_asm();shuzuhang_count33=PORTA;_asm();shuzuhang_count34=PORTA;_asm(); shuzuhang_count35=PORTA;_asm();shuzuhang_count36=PORTA;_asm();shuzuhang_count37=PORTA;_asm();shuzuhang_count38=PORTA;_asm();shuzuhang_count39=PORTA;_asm(); shuzuhang_count40=PORTA;_asm();shuzuh

16、ang_count41=PORTA;_asm();shuzuhang_count42=PORTA;_asm();shuzuhang_count43=PORTA;_asm();shuzuhang_count44=PORTA;_asm(); shuzuhang_count45=PORTA;_asm();shuzuhang_count46=PORTA;_asm();shuzuhang_count47=PORTA;_asm();shuzuhang_count48=PORTA;_asm();shuzuhang_count49=PORTA;_asm(); shuzuhang_count50=PORTA;_

17、asm();shuzuhang_count51=PORTA;_asm();shuzuhang_count52=PORTA;_asm();shuzuhang_count53=PORTA;_asm();shuzuhang_count54=PORTA;_asm(); shuzuhang_count55=PORTA;_asm();shuzuhang_count56=PORTA;_asm();shuzuhang_count57=PORTA;_asm();shuzuhang_count58=PORTA;_asm();shuzuhang_count59=PORTA;_asm(); shuzuhang_cou

18、nt60=PORTA;_asm();shuzuhang_count61=PORTA;_asm();shuzuhang_count62=PORTA;_asm();shuzuhang_count63=PORTA;_asm();shuzuhang_count64=PORTA;_asm(); shuzuhang_count65=PORTA;_asm();shuzuhang_count66=PORTA;_asm();shuzuhang_count67=PORTA;_asm();shuzuhang_count68=PORTA;_asm();shuzuhang_count69=PORTA;_asm(); s

19、huzuhang_count70=PORTA;_asm();shuzuhang_count71=PORTA;_asm();shuzuhang_count72=PORTA;_asm();shuzuhang_count73=PORTA;_asm();shuzuhang_count74=PORTA;_asm(); shuzuhang_count75=PORTA;_asm();shuzuhang_count76=PORTA;_asm();shuzuhang_count77=PORTA;_asm();shuzuhang_count78=PORTA;_asm();shuzuhang_count79=POR

20、TA;_asm(); shuzuhang_count80=PORTA;_asm();shuzuhang_count81=PORTA;_asm();shuzuhang_count82=PORTA;_asm();shuzuhang_count83=PORTA;_asm();shuzuhang_count84=PORTA;_asm(); shuzuhang_count85=PORTA;_asm();shuzuhang_count86=PORTA;_asm();shuzuhang_count87=PORTA;_asm();shuzuhang_count88=PORTA;_asm();shuzuhang

21、_count89=PORTA;_asm(); shuzuhang_count90=PORTA;_asm();shuzuhang_count91=PORTA;_asm();shuzuhang_count92=PORTA;_asm();shuzuhang_count93=PORTA;_asm();shuzuhang_count94=PORTA;_asm(); shuzuhang_count95=PORTA;_asm();shuzuhang_count96=PORTA;_asm();shuzuhang_count97=PORTA;_asm();shuzuhang_count98=PORTA;_asm

22、();shuzuhang_count99=PORTA;_asm(); for(j=0;j100;j+,p+) *p=shuzuhang_countj; hang_count+; if(hang_count=hangshu) TIE=0x00; /关行中断,场中断 SCI_Send_Byte(0x01); SCI_Send_Image_String(&shuzu00,hangshu*lieshu); SCI_Send_Byte(0x01); TIE=0x02; /开场中断 return; /* 功能描述:场中断服务程序,接PT1参数说明:返回说明: 修改记录:注意事项:*/#pragma CODE_SEG NON_BANKED interrupt 9 void PT1_Interrupt(void) TFLG1=0x03; /清场中断,行中断TIE=0x03; /开场中断,关行中断hang=0;lie=0;hang_count=0; Welcome ToDownload !欢迎您的下载,资料仅供参考!

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1