欢迎来到天天文库
浏览记录
ID:38565818
大小:812.50 KB
页数:51页
时间:2019-06-15
《飞思卡尔C语言》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、2008-08-3122:43求飞思卡尔智能车程序悬赏分:80-解决时间:2008-3-512:53求飞思卡尔智能车的数据采集(CCD摄像头)程序,舵机,电机控制程序。主控芯片为MC9S12DG128的汇编程序.硬件设计尚未完成,只要求实现基本功能即可.注释越详细越好.答案满意会加分.-----------------------------------------------/*************************************************************************************Test.c*D
2、escription:ThisfileincludesI/Ofunctionfortest,thePWMoutputsfunctionfortest,function*testingsensors.*(c)Copyright2006,ZhaoCheng*AllRightsReserved**By:ZhaoCheng*Note:Don'tchangethisfileifpossible.**********************************************************************************/#includ
3、e#include#defineHIGHSPEED8000#defineLOWSPEED11000/*速度变量,0-24000数值越大,速度越慢*/voidPWMout(int,int);/*24000-20000*/voidIOtest(void){staticunsignedchari=0,j=0x01,k;DDRB=DDRA=0xFF;PORTB=0xf0;for(;;){k=(~j)&0x7f;PORTA=PORTB=k;while(TCNT!=0x0000);while(TCNT==0x0000){if(
4、i>9){j=j<<1;i=0;}i++;}if(j>=0x80)j=0x01;}}voidPWMtest(void){intcounter=-4500;DDRB=0xff;PORTB=0xff;TSCR1=0x80;/*enabletimerTCNT*/TSCR2=0x00;/*TCNTprescalersetup*/for(;;){while(TCNT!=0x0000);while(TCNT==0x0000);counter=counter+30;if(counter>=3000){counter=0;PWMout(4500,LOWSPEED);}if(co
5、unter==1500){PWMout(-4500,LOWSPEED);}PORTB=(char)(counter/100);}}voidSignalTest(void){unsignedcharsignal;intDirection,Velocity;Direction=0;Velocity=LOWSPEED;DDRA=0x00;DDRB=0xff;signal=PORTA;PORTB=~signal;switch(signal){case0x08:/*00011000*/case0x10:Direction=800;Velocity=HIGHSPEED;br
6、eak;case0x04:/*00100100*/case0x20:Direction=1500;Velocity=HIGHSPEED;break;case0x02:/*01000010*/case0x40:Direction=2800;Velocity=HIGHSPEED;break;case0x01:/*10000001*/case0x80:Direction=4000;Velocity=LOWSPEED;break;case0x3c:/*00111100overstartline*/case0xff:/*11111111overcrossingline*/
7、case0x00:/*00000000gostraightnotneedchangedstate*/default:break;}if(signal>0x0f)Direction=-Direction;PWMout(Direction,LOWSPEED);}/*************************************************************************************LCD1620.c*ICC-AVRapplicationbuilder:2006-1-821:43:48*Target:M8*Crysta
8、l:4.0000Mhz*
此文档下载收益归作者所有