为啥中断会持续调用啊??我只是在满足条件if(num2==1)的时候调用了一次而已啊!求大神开导,万分感谢
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar num2,num,t,temp,temp1;
sbit beep=P1^5;
uchar code table1[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar code table2[]={
0x7f,0xbf,0xdf};
void timer0();
void delay (uint);
void delay (uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
beep=0;
t=0;
EA=1;
ET0=1;
//TF0=1
TMOD=0x01;
TR0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
while(1)
{
P0=table1[num];
P2=table2[num2];
delay(800);
num++;
if(num==10)
{
num=0;
num2++;
/*
timer0();*/
}
if(num2==2)
{
num2=0;
beep=1;
}
if(num2==1)
{
timer0();
P0=0xff;
}
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t++;
//P0=0xff;
if(t==20)
{
t=0;
beep=1;
P2=0xff;
delay(300);
P2=table2[num2];
beep=0;
delay(300);
}
} |