stc89c52这个程序为什么只执行一次外部中断函数,再次按下开关就不执行外部中断函数
时间:10-02
整理:3721RD
点击:
#include <reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit deng=P3^7;
sbit jinshu=P1^4;
void delay_1ms(unsigned int a)
{
unsigned int i;
while( a-- != 0){
for(i = 0; i < 552; i++);
}
}
void ini_int1(void)
{
EA=1;
EX1=1; //开启外部中断 0
IT1=0;
//TCON=0x04;
}
void Int1() interrupt 2 using 2 //使用外部中断1,寄存器组3
{ EX1=0;//关闭中断
dengliang=dengliang+1;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
}
void main(void)
{
ini_int1();
while(1)
{ deng=0;
if(jinshu==0)//按键按下打开中断
{
delay_1ms(10);
if(jinshu==0)
{
EX1=1;
}
}
}
}
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit deng=P3^7;
sbit jinshu=P1^4;
void delay_1ms(unsigned int a)
{
unsigned int i;
while( a-- != 0){
for(i = 0; i < 552; i++);
}
}
void ini_int1(void)
{
EA=1;
EX1=1; //开启外部中断 0
IT1=0;
//TCON=0x04;
}
void Int1() interrupt 2 using 2 //使用外部中断1,寄存器组3
{ EX1=0;//关闭中断
dengliang=dengliang+1;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
}
void main(void)
{
ini_int1();
while(1)
{ deng=0;
if(jinshu==0)//按键按下打开中断
{
delay_1ms(10);
if(jinshu==0)
{
EX1=1;
}
}
}
}
中断里面干的事情太过了吧