#include
#include
sbit P20=P2^0;
//sbit P01=P0^1;
//sbit P02=P0^2;
//sbit P07=P0^7;
code timer[]={
char
unsigned char count=0;
unsigned
28,28,29,29,30,30,30,31,31,31,
32,32,33,33,33,34,34,34,35,35,
36,36,36,37,37,37,38,38,38,39,
39,39,40,40,40,41,41,41,42,42,
42,43,43,43,43,44,44,44,44,45,
45,45,45,46,46,46,46,47,47,47,
47,47,47,48,48,48,48,48,48,49,
49,49,49,49,49,49,49,49,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,49,49,49,49,49,49,49,49,
49,48,48,48,48,48,48,47,47,47,
47,47,47,46,46,46,46,45,45,45,
45,44,44,44,44,43,43,43,43,42,
42,42,41,41,41,40,40,40,39,39,
39,38,38,38,37,37,37,36,36,36,
35,35,34,34,34,33,33,33,32,32,
31,31,31,30,30,30,29,29,28,28,
28,27,27,26,26,26,25,25,24,24,
24,23,23,23,22,22,21,21,21,20,
20,20,19,19,19,18,18,18,17,17,
16,16,16,16,15,15,15,14,14,14,
13,13,13,12,12,12,12,11,11,11,
11,10,10,10,10, 9, 9, 9, 9, 9,
8, 8, 8, 8, 8, 8, 7, 7, 7, 7,
7, 7, 7, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 7, 7, 7,
7, 7, 7, 7, 8, 8, 8, 8, 8, 8,
9, 9, 9, 9, 9,10,10,10,10,11,
11,11,11,12,12,12,12,13,13,13,
14,14,14,15,15,15,16,16,16,16,
17,17,18,18,18,19,19,19,20,20,
20,21,21,21,22,22,23,23,23,24,
24,24,25,25,26,26,26,27,27,28};
void main(void){
// TMOD=0000 0110B,使用计数器 T0 的模式 2
//开总中断
//允许定时器 T0 的中断
//允许外中断 INT0
//INT0 为下负脉冲触发方式
TMOD=0x02;
EA=1;
ET0=1;
EX0=1;
IT0=1;
TH0=TL0=256-timer[0];
TR0=1;
P20=1;
while(1);
//启动 T0
}
void Key_counter() interrupt 1 using 0
{
if(P20==1){
P20=0;
TL0=200+timer[count]; //256-(56-timer[])
TH0=200+timer[count];
if(count==359){
count=0;
}
}
else{
P20=1;
TL0=256-timer[++count];
TH0=256-timer[++count];
}
}