比如这个程序的一个中断在进入定时中断后,并执行完定时中断不就进入while()循环了吗???那么定时中断不就只执行一次吗???怎么tine的值会加到4000呢????这个中断到底是怎么进入的 从哪一步开始进入中断的啊??? 新手自学 高手莫笑
main()
{
TMOD=(TMOD & 0xf0) | 0x02; //T0工作模式是方式2
TH0=0x06; //定义初始值为0.06ms,计时0.256ms-0.06ms=0.25ms
TL0=0x06;
TR0=1; //开启T0计时
EA=1;
ET0=1;
while(1)
{
display(count1/10,count1%10,count2/10,count2%10);
}
}
void timer0() interrupt 1 using 0 //T0中断
{
TH0=0x06;
TL0=0x06;
time++;
if(time==4000) //4000*0.25ms=1000ms=1s
{
time=0;
count1--;
if(count1==0)
{
count1=59;
count2--;
if(count2==0)
{
count2=59;
}
}
}
}