#include <reg52.h>
unsigned char tcount2s;
unsigned char tcount02s;
unsigned char ID;
sbit key1=P1^0;
sbit key2=P1^1;
sbit key3=P1^2;
sbit key4=P1^3;
void main(void)
{
TMOD=0x01;
TH0=0x3c;
TL0=0xb0;
TR0=1;
ET0=1;
EA=1;
while(1);*************调试的时候死循环在这里,不进入下面的子程序?
}
void t0(void) interrupt 1 using 0
{
tcount2s++;
if(tcount2s==40)
{
tcount2s=0;
ID++;
if(ID==4)
{
ID=0;
}
}
tcount02s++;
if(tcount02s==4)
{
tcount02s=0;
switch(ID)
{
case 0:
key1=~key1;
break;
case 1:
key2=~key2;
break;
case 2:
key3=~key3;
break;
case 3:
key4=~key4;
break;
}
}
}
***********为何实验结果是四个灯互相交替闪烁,但是P1.0控制的L1却一直亮着?
跪求解答!!!! |