疑点,外部中断0采用电平触发方式,一直将P3.2插在GND上,P1.2连接LED1,但是数码管还是会闪烁前进(从0到F),只是比未插到GND时的间隔时间变长了而已。
#include<reg52.h>
void delay(uint);
#define uint unsigned int
#define uchar unsigned char
uchar temp;
uint i=0;
sbit Dx=P2^2;
sbit Wx=P2^3;
sbit D1=P1^2;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void main()
{
EA=1;
EX0=1;
IT0=0;
for(i=0;i<16;i++)
{
temp=table;
P0=temp;
Dx=1;
Dx=0;
temp=0x55;
P0=temp;
Wx=1;
Wx=0;
delay(100);
}
while(1);
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=1000;y>0;y--);
}
void EXTER0() interrupt 0
{
D1=!D1;
}