資源描述:
《飛思卡爾C語言》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、2008-08-3122:43求飛思卡爾智能車程序懸賞分:80-解決時(shí)間:2008-3-512:53求飛思卡爾智能車的數(shù)據(jù)采集(CCD攝像頭)程序,舵機(jī),電機(jī)控制程序。主控芯片為MC9S12DG128的匯編程序.硬件設(shè)計(jì)尚未完成,只要求實(shí)現(xiàn)基本功能即可.注釋越詳細(xì)越好.答案滿意會(huì)加分.-----------------------------------------------/*************************************************************************************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數(shù)值越大,速度越慢*/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*