-
大小: 74KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-05-09
- 語言: 其他
- 標(biāo)簽: STC12C2052AD??C語言??
資源簡介
STC12C2052AD的參考例程,包含CPU初始化,定時器、按鍵處理和定時中斷等

代碼片段和文件信息
/****************************************************************************
?**
?**?文件名:??main.c
?**?功能:????
?**?創(chuàng)建時間:2006.11.09
?**?修改時間:
?**?修改說明:
?**?作者:????李立學(xué)
?**?版權(quán)申明:可以拷貝,可以修改,但必須保留修改時間和作者信息
?**?
?****************************************************************************/
#include?“..\config\INCLUDES.H“
Int8U?bdata?SYSTEM_FLAG?=?0;????????????
sbit?TIME_SEC_Flag?????=?SYSTEM_FLAG^0;??//?Second?Flag.?
sbit?TIME_100mSEC_Flag?=?SYSTEM_FLAG^1;??//?Second?Flag.?
sbit?LED0_ON_Flag??????=?SYSTEM_FLAG^2;??//?.?
sbit?T0_INTR_Flag??????=?SYSTEM_FLAG^3;
Int32U?idata?IntrTimesCnt?=?0;?????????//?秒信號計數(shù)
/*
?定時器0每100uS產(chǎn)生1次中斷,對中斷次數(shù)進行計數(shù),每計滿10000次即為1秒。
?*/
Int8U??idata?TimeSlotCnt?=?0;??????????//?時隙計數(shù)(0-4)
Int8U??idata?ADC_SetTime0Val?=?0;
/*
?左電位器對應(yīng)的電壓采樣值。
?*/
Int8U??idata?ADC_SetTime1Val?=?0;
/*
?右電位器對應(yīng)的電壓采樣值。
?*/
Int8U??idata?ADC_SetSpeedVal?=?0;
/*
?中間電位器對應(yīng)的電壓采樣值。
?*/
???
Int8U?idata?PWM0Soft_IntrTimesCnt?=?0x00;???//?.
Int8U?idata?PWM1Soft_IntrTimesCnt?=?0x00;???//?.
Int8U?idata?PWM0Soft_DutyVal?=?0xff;????????//?100%.
/*
?左前輪旋轉(zhuǎn)速度控制;最小值為0,對應(yīng)電機停轉(zhuǎn);最大值為255,對應(yīng)電機最高轉(zhuǎn)速。
?*/
Int8U?idata?PWM1Soft_DutyVal?=?0x80;????????//??50%.
/*
?右前輪旋轉(zhuǎn)速度控制;最小值為0,對應(yīng)電機停轉(zhuǎn);最大值為255,對應(yīng)電機最高轉(zhuǎn)速。
?*/
??
Int8U?bdata?CAR_FLAG?=?0;??
sbit?CAR_MoveEN?=?CAR_FLAG^0;??????//?0/1:?STOP/Moving.
? ??
Int16U?idata?SW0_PreTimCnt?=?0;
Int8U??idata?SW0_PreEvtCnt?=?0;
Int16U?idata?SW1_PreTimCnt?=?0;
Int8U??idata?SW1_PreEvtCnt?=?0;
Int16U?idata?SW2_PreTimCnt?=?0;
Int8U??idata?SW2_PreEvtCnt?=?0;
Int16U?idata?SW3_PreTimCnt?=?0;
Int8U??idata?SW3_PreEvtCnt?=?0;
/****************************************************************************
?**?函數(shù)名稱:?T0_ISR()
?**?功能描述:?定時器0中斷服務(wù)程序,定時間隔100uS
?**?入口參數(shù):?無
?**?出口參數(shù):?無
?**?全局變量:?無
?**?調(diào)用模塊:?無
?**?說明:?
?****************************************************************************/
void?T0_ISR(void)?interrupt?1?????//?Interrupt?Interval:?100uS.?
{
//????Int8U??i;
???/*****************************************************************
????**?TIMER?Interrupt?SLOT?0?
????*****************************************************************/
????if(?TimeSlotCnt?==?0?)
????{
// ????ADC_SetTime0Val?=?ADC_GetSample(ADC_MUX_P10);??//?Acq?P10(SetTime0).
????}?
???/*****************************************************************
????**?TIMER?Interrupt?SLOT?1??
????*****************************************************************/
????if(?TimeSlotCnt?==?1?)
????{
// ????ADC_SetSpeedVal?=?ADC_GetSample(ADC_MUX_P11);??//?Acq?P11(SetSpeed).
????ADC_SetSpeedVal?=?ADC_GetSample(ADC_MUX_P11);??//?Acq?P11(SetSpeed).
????}?
???/*****************************************************************
????**?TIMER?Interrupt?SLOT?2?time?Interval:?625uS??
????*****************************************************************/
????if(?TimeSlotCnt?==?2?)
????{
// ????ADC_SetTime1Val?=?ADC_GetSample(ADC_MUX_P12);??//?Acq?P12(SetTime1).
????}?
???/*********************
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2012-03-19?22:39??RobotCarDemoLib_STC12C2052AD_20120318
?????文件???????4557??2012-03-19?22:21??RobotCarDemoLib_STC12C2052AD_20120318\ADC.lst
?????目錄??????????0??2012-03-19?22:30??RobotCarDemoLib_STC12C2052AD_20120318\app
?????文件??????12606??2012-03-19?22:39??RobotCarDemoLib_STC12C2052AD_20120318\app\main.c
?????文件????????419??2010-07-19?10:27??RobotCarDemoLib_STC12C2052AD_20120318\app\MAIN.H
?????目錄??????????0??2012-03-19?22:30??RobotCarDemoLib_STC12C2052AD_20120318\board
?????目錄??????????0??2012-03-19?22:30??RobotCarDemoLib_STC12C2052AD_20120318\config
?????文件???????2108??2011-10-10?11:12??RobotCarDemoLib_STC12C2052AD_20120318\config\DATATYPE.H
?????文件???????1297??2012-03-19?21:40??RobotCarDemoLib_STC12C2052AD_20120318\config\INCLUDES.H
?????目錄??????????0??2012-03-19?22:32??RobotCarDemoLib_STC12C2052AD_20120318\cpu
?????文件???????1893??2012-03-19?22:18??RobotCarDemoLib_STC12C2052AD_20120318\cpu\ADC.H
?????文件???????9657??2012-03-19?22:21??RobotCarDemoLib_STC12C2052AD_20120318\cpu\ADC.obj
?????文件???????2849??2012-03-10?20:14??RobotCarDemoLib_STC12C2052AD_20120318\cpu\CPUINIT.H
?????文件??????11662??2012-03-19?22:21??RobotCarDemoLib_STC12C2052AD_20120318\cpu\CpuInit.obj
?????文件??????16401??2011-10-23?23:45??RobotCarDemoLib_STC12C2052AD_20120318\cpu\main.obj
?????文件???????5115??2002-04-16?14:32??RobotCarDemoLib_STC12C2052AD_20120318\cpu\STARTUP.A51
?????文件????????816??2011-10-23?23:45??RobotCarDemoLib_STC12C2052AD_20120318\cpu\STARTUP.obj
?????文件???????4138??2012-03-19?21:50??RobotCarDemoLib_STC12C2052AD_20120318\cpu\STC12C2052AD.h
?????文件???????2925??2011-10-12?19:22??RobotCarDemoLib_STC12C2052AD_20120318\cpu\TIMER.H
?????文件??????10393??2012-03-19?22:21??RobotCarDemoLib_STC12C2052AD_20120318\cpu\timer.obj
?????文件???????6643??2012-03-19?22:21??RobotCarDemoLib_STC12C2052AD_20120318\CpuInit.lst
?????文件??????25067??2012-03-19?22:39??RobotCarDemoLib_STC12C2052AD_20120318\main.lst
?????目錄??????????0??2012-03-19?22:39??RobotCarDemoLib_STC12C2052AD_20120318\output
?????文件???????9657??2012-03-19?22:21??RobotCarDemoLib_STC12C2052AD_20120318\output\ADC.obj
?????文件??????11662??2012-03-19?22:21??RobotCarDemoLib_STC12C2052AD_20120318\output\CpuInit.obj
?????文件??????18203??2012-03-19?22:39??RobotCarDemoLib_STC12C2052AD_20120318\output\main.obj
?????文件?????????93??2012-03-19?22:39??RobotCarDemoLib_STC12C2052AD_20120318\output\main.__i
?????文件??????47312??2012-03-19?22:39??RobotCarDemoLib_STC12C2052AD_20120318\output\RobotCar
?????文件???????4598??2012-03-19?22:39??RobotCarDemoLib_STC12C2052AD_20120318\output\RobotCar.hex
?????文件????????171??2012-03-19?22:39??RobotCarDemoLib_STC12C2052AD_20120318\output\RobotCar.lnp
............此處省略13個文件信息
評論
共有 條評論