#include "reg52.h"
#define uchar unsigned char
#define uint unsigned int
sbit led1 = P1^0;
uchar num;
uchar code table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
sbit wela = P2^7;
sbit dula = P2^6;
uchar m;
void delayms(uint);
void main()
{
TMOD = 0x01;
TH0 = (65536-45872)/256;
TL0 = (65536-45872)%256;
EA = 1;
ET0 = 1;
TR0 = 1;
while(1)
{
wela = 1;
P0 = 0xfe;
wela = 0;
for(m = 0;m < 16;m++)
{
dula = 1;
P0 = table[m];
dula = 0;
delayms(500);
}
}
}
void T0_time() interrupt 1
{
TH0 = (65536-45872)/256;
TL0 = (65536-45872)%256;
num++;
if(num == 20)
{
num = 0;
led1 = ~led1;
}
}
void delayms(uint xms)
{
uint i,j;
for(i = xms ;i > 0;i--)
for(j = 110;j > 0;j--);
}
这是一个中断程序,我想问两个问题
1这个程序的执行顺序是怎么样的?
2怎么中断产生的时候数码管也同时在亮呢 不应该是去执行中断程序么~~~ |