中段进入的时候,一般是把自己会用到的寄存器推入堆栈,把中断关了,做相应 *** 作完成后,把中断打开,d出堆栈原推入的寄存器,退出中断
#include "reg52.h"sbit key=P3^2
void main()
{
IT0=1//外部中断0连沿触发方式
EX0=1//使能外部中断0
EA=1//开部中断
while(1)
}
void int0() interrupt 0
{
int tab[]={0xff,0x7f,0xbf,0x3f,0xdf,0x5f,0x9f,0x1f,0xef,0x6f,0xaf,0x2f,0xcf,0x4f,0x8f,0x0f}
int count=15
long int i
while(1)
{
if(key==0)
for(i=0i<10000i++)
if(key==0)
{ count--
if(count==0)
count=15
P3= tab[count]
while(key==0)
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)