写外部中断跟写延时函数是同理的,唯一的不同是要在主函数main 中打开中断开关(EA=1;
EX0=1;
IT0=0;)
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit D1=P2^1;
unsigned char table[]={0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char table1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd};
void delay_50ms(uint t)
{
uint k;
for(;t>0;t--)
for(k=6245;k>0;k--);
}
void int0() interrupt 0
{
unsigned char m;
while(1)
for(m=0;m<14;m++)
{
P1=table1[m];
delay_50ms(10);
}
}
void main()
{
uchar i;
EA=1;
EX0=1;
IT0=0;
D1=0;
while(1)
{
for(i=0;i<9;i++)
{
P0=table[i];
delay_50ms(20);
}
}
}
中断可以实现,但我想在中断中嵌套中断却无法实现