欢迎来到天天文库
浏览记录
ID:57645633
大小:83.00 KB
页数:12页
时间:2020-08-30
《飞思卡尔智能车程序.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Main.c#include/*commondefinesandmacros*/#include/*derivativeinformation*/#pragmaLINK_INFODERIVATIVE"mc9s12db128b"#include"define.h"#include"init.h"//variableusedinvideoprocessvolatileunsignedcharimage_data[ROW_MAX][LINE_MAX];//dataarrayofpictureunsignedcharblack_x[ROW_MAX
2、];//0ne-dimensionalarrayunsignedcharrow;//x-positionofthearrayunsignedcharline;//y-positionofthearrayunsignedintrow_count;//rowcounterunsignedcharline_sample;//usedtocounterinADunsignedcharrow_image;unsignedcharline_temp;//temperaryvariableusedindatatransferunsignedcharsample_data[LINE_MAX];//us
3、edtosaveone-dimensionarraygotininterruption//variablesbelowareusedinspeedmeasureUnsignedcharpulse[5];//usedtosavedatainPAprocessUnsignedcharcounter;//temporarycounterinSpeeddetectUnsignedcharcur_speed;//currentspeedshortstand;shortdata;unsignedcharcurve;//valveusedtodecidestraightorturnshortBoun
4、ds(shortdata);shortFuzzyLogic(shortstand);/*----------------------------------------------------------------------------*receive_sci*----------------------------------------------------------------------------*/unsignedcharreceive_sci(void)//receivedatathroughsci{unsignedcharsci_data;while(SCI
5、0SR1_RDRF!=1);sci_data=SCI0DRL;returnsci_data;}/*----------------------------------------------------------------------------*transmit_sci*----------------------------------------------------------------------------*/voidtransmit_sci(unsignedchartransmit_data)//senddatathroughsci{while(SCI0SR1
6、_TC!=1);while(SCI0SR1_TDRE!=1);SCI0DRL=transmit_data;}/********************************************************************************//*----------------------------------------------------------------------------*abs_sub*-----------------------------------------------------------------------
7、-----*/unsignedcharabs_sub(unsignedcharnum1,unsignedcharnum2){unsignedchardifference;if(num1>=num2){difference=num1-num2;}else{difference=num2-num1;}returndifference;}voidpwm_set(unsignedintdutycycle){PWMDTY1=dutycycle&0x00F
此文档下载收益归作者所有