📄 tickisr.c
字号:
#include <e51.h>
#include <reg51.h>
#define OFF 0
#define ON 1
uchar Tick=0;
uchar Key;
extern uchar DisBuf[4] ;
extern unsigned int ReadTemperature(void);
void tickISR () interrupt 1
{
static uchar LedPos =0;
static uchar Key_Sta=OFF;
static uchar Key_time=0;
TH0=-2000/256;
TL0=-2000%256;
LedPos++;//Led show pos
if(LedPos==4) LedPos=0;
Tick++;//tick
if(Tick>=50) Tick=0;//1s
DisBuf[LedPos]|=(LedPos<<4);
P2= DisBuf[LedPos];
if((P3&0x0c)!=0x0c&&Key_Sta==OFF) {Key_Sta=ON; Key=P3&0x0c;}
if(Key_Sta==ON) Key_time++;
//if(Key_time==1&&Key_Sta==ON) Key=P3&0x0c;
if((P3&0x0c)==0x0c&&Key_Sta==ON)
{
// P17=~P17;
Key_Sta=OFF;
Key_time=0;
// if(Key_time>49&&Key==0x04){Key|=0x40;Key_time=0;}
Key|=0x80;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -