51单片机外部中断自动重复了一次
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
void delay(uint);
void breath();
uchar tr_1;
void main()
{
EX0=1;
IT0=1;
EA=1;
P0=0xfe;
delay(4000);
while(1)
{
tr_1=P0;
P0=_crol_(P0,1);
tr_1=P0;
delay(4000);
}
}
void breath()
{
uint count_1;
count_1=0;
while(count_1<100)
{
P0=0xff;
delay(100-count_1);
P0=0x00;
delay(count_1);
count_1++;
}
while(count_1>0)
{
P0=0x00;
delay(count_1);
P0=0xff;
delay(100-count_1);
count_1--;
}
P0=tr_1;
}
void delay(uint t)
{
uint count_1;
while(t>0)
{
for(count_1=0;count_1<5;count_1++);
t--;
}
}
void led() interrupt 0
{
uint count_1;
count_1=0;
while(count_1<1)
{
breath();
count_1++;
}
}
点击了外部中断按钮之后,应该只出现一次呼吸灯的亮和灭,可是实际上有时候是一次,有时候是两次。???求助