-
大小: 74KB文件类型: .rar金币: 2下载: 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个文件信息
- 上一篇:机器学习 tom版教材 课后题部分答案
- 下一篇:基于VHDL的GPS设计
相关资源
- MP3文件ID3v2ID3v2APEv2标签读取
- 课程作业:模拟仓库管理系统
- 一个简单实用个人日记管理系统
- 带时间温度显示的室内灯光控制系统
- 成绩管理系统(数据结构)
- FIR低通滤波器 ccs运行环境
- C malloc函数用法
- 嵌入式局域网聊天系统客户端
- 算法竞赛入门经典 第2版刘汝佳+高清
- 基于单片机的GPS定位及显示系统设计
- 链表实现通讯录管理系统
- PowerShell-6.2.1-win-x86.zip
- pl/0编译器 语法分析
- 源程序阅读与调试课程设计报告--学生
- 谁说程序员不浪漫?!基于easyX图形库
- 编译原理课设c编译器
- MCP3421 STM32 Driver
- ADS1100 STM32 Driver
- 单片机89c52与MLX90614红外的测温程序
- stm32f103AES加密 cbc模式
- 单片机 点阵 字模提取软件
- C高级编程讲义-传智播客
- NOIP必学内容之前缀和与差分颜鸿宇
- Skyline高效检索算法实现.zip
- STM8S103系列IO模拟串口通信实现真正串
- stm32f103c8t6移植uC/OS-III基于HAL库的工程
- 温度、一氧化碳、二氧化碳、PM2.5以及
- 王道论坛计算机考研机试指南
- 有限元中网格剖分算法
- PLC开源资料
评论
共有 条评论