




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
最终还是没能赶上校内赛,虽然是很伤心,在这里只想现在的,以后的孩子不要再话那么多的时间在图像采集方面,可以放多点时间在数据处理方面,以免重蹈我们的悲剧,现在上传上位机程序,如果你喜欢,可以买个20块的上位机(淘宝有),这样就可以看到图像。(PS:绝对没有帮他们卖广告的嫌疑,只是想同学们可以早点搞好图像。)/T0接受行中断,上升沿触发,T1接受场中断,下降沿触发/数据口为PA0-PA7/波特率为115200/串口分别接单片机S0 S1/图像大小选择 60*30 /设置帧头帧尾为0x01#include /* common defines and macros */#include derivative.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,centerhangshu,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;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; 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; /舵机静止占空比为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) PWMDTY01=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=0xFF; /清除该位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_String(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(putcharcounter); 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参数说明:返回说明: 修改记录:注意事项:*/#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_count2=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_count12=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();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=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();shuzuhang_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;_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_count60=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(); shuzuhang_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=PORTA;_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_count89=PORTA;_asm(); shuzuhang_count90=PORTA;_asm
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 贵池区安全员证考及答案1
- 高职教师教学胜任力提升的有效策略
- 脐橙产业发展趋势与应对措施
- 老旧建筑健康监测系统设计与应用探索
- 土味水晶鞋营销方案
- 2025年交通工程安全题库及答案
- 三级语文百科知识竞赛题及答案
- 养殖专业模拟试题及答案
- 7.2 三角函数概念说课稿-2025-2026学年高中数学苏教版2019必修第一册-苏教版2019
- 医学招聘专业测试题及答案
- 刑法学课程课件教案绪论
- 精神科量表完整版本
- 混凝土搅拌站安全生产管理制度(2篇)
- 讲好中国故事英语演讲2-3分钟
- 跨境电商实务 课件 项目一 跨境电商概述
- 旗袍赛活动方案
- 大学高数-函数和极限省公开课获奖课件说课比赛一等奖课件
- PDCA血液透析水循环案例汇报
- DB13T 5971-2024 从业人员健康检查技术规范
- GB/T 7260.3-2024不间断电源系统(UPS)第3部分:确定性能和试验要求的方法
- 向左向右转 体育与健康一年级下册
评论
0/150
提交评论