外部中断0启动后,返回主函数无法启动外部中断1
#include<reg52.h>
#define ulint unsigned long int
#define uchar unsigned char
sbit up=P1^0;
sbit down=P1^1;
sbit PW1=P1^2;
sbit PW2=P1^3;
#define motorup PW1=0; PW2=1;
#define motordown PW1=1; PW2=0;
#define stop PW1=1; PW2=1;
void delay(ulint z)
{
ulint x,y;
for(x=z;x>0;x--);
for(y=4294967290;y>0;y--);
}
void main()
{
EA=1;
EX0=1;
EX1=1;
IT0=0;
IT1=1;
PX0=1;
while(1)
{
stop;
EX0=1;
if(up==0&&down==1)
{
motorup;
}
else if(up==0&&down==0)
{
stop;
}
else if(up==1&&down==0)
{
motordown;
}
else if(up==1&&down==1)
{
stop;
}
}
}
void autostop() interrupt 0
{
stop;
main();
}
void autodo() interrupt 2
{
motordown;
delay(50000);
} |