#define ALLOCATE_EXTERN
#include "HC89S003F4.h"
sbit KEY = P2^7;
sbit LED = P0^0;
#define N_KEY 0
#define S_KEY 1
#define D_KEY 2
#define L_KEY 10
#define MOTO_ON() PWM0DH = 0x01; PWM0DL = 0xF4;
#define MOTO_OFF() PWM0DH = 0x00; PWM0DL = 0x00;
bit FlagSysClk10ms; //10ms标记位
bit FlagSysClk500ms; //500ms标记位
unsigned char KeyValue = 0;
unsigned char CntSysClk10ms = 0; //时钟10MS记数
unsigned char CntSysClk500ms = 0; //时钟500MS记数
unsigned int Bat_Adc = 0; //电池电量
/***************************************************************************************
*延时函数*
***************************************************************************************/
void Delay_2us(unsigned int fui_i) //2us延时
{
while(fui_i--);
}
void Delay_ms(unsigned int fui_i) //1ms延时
{
unsigned int fui_j;
for(;fui_i > 0;fui_i --)
for(fui_j = 1596;fui_j > 0;fui_j --);
}
|