• 大小: 74KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: 其他
  • 标签: STC12C2052AD  C语言  

资源简介

STC12C2052AD的参考例程,包含CPU初始化,定时器、按键处理和定时中断等

资源截图

代码片段和文件信息

/****************************************************************************
 **
 ** 文件名:  main.c
 ** 功能:    
 ** 创建时间:2006.11.09
 ** 修改时间:
 ** 修改说明:
 ** 作者:    李立学
 ** 版权申明:可以拷贝,可以修改,但必须保留修改时间和作者信息
 ** 
 ****************************************************************************/
#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;         // 秒信号计数
/*
 定时器0每100uS产生1次中断,对中断次数进行计数,每计满10000次即为1秒。
 */
Int8U  idata TimeSlotCnt = 0;          // 时隙计数(0-4)


Int8U  idata ADC_SetTime0Val = 0;
/*
 左电位器对应的电压采样值。
 */
Int8U  idata ADC_SetTime1Val = 0;
/*
 右电位器对应的电压采样值。
 */
Int8U  idata ADC_SetSpeedVal = 0;
/*
 中间电位器对应的电压采样值。
 */

   
Int8U idata PWM0Soft_IntrTimesCnt = 0x00;   // .
Int8U idata PWM1Soft_IntrTimesCnt = 0x00;   // .
Int8U idata PWM0Soft_DutyVal = 0xff;        // 100%.
/*
 左前轮旋转速度控制;最小值为0,对应电机停转;最大值为255,对应电机最高转速。
 */
Int8U idata PWM1Soft_DutyVal = 0x80;        //  50%.
/*
 右前轮旋转速度控制;最小值为0,对应电机停转;最大值为255,对应电机最高转速。
 */
  
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;


/****************************************************************************
 ** 函数名称: T0_ISR()
 ** 功能描述: 定时器0中断服务程序,定时间隔100uS
 ** 入口参数: 无
 ** 出口参数: 无
 ** 全局变量: 无
 ** 调用模块: 无
 ** 说明: 
 ****************************************************************************/
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个文件信息

评论

共有 条评论