然后在主程序中像调用子函数一样调用就可以了
举个例子吧
#define uchar unsigned char
#define uchar unsigned char
sbit D1=P1^0
uchar aa
void init()
{
TMOD=0x01
TH0=(65536-50000)/256
TL0=(65536-50000)%256
EA=1
ET0=1
TR0=1
}
void main()
{
init()
while(1)
{
if(aa==20)
{
D1=~D1
aa=0
}
}
}
void T0time()interrupt 1
{
TH0=(65536-50000)/256
TL0=(65536-50000)%256
aa++
}
1.void(中断函数返回类型(空型)) Time1 (中断函数名)(void(参数类型) interrupt 3 (中断号)2: 中断条件发生时执行中断,比如void Time1(void) interrupt 3 是定时器1定时时间到发生中断,中断函数放在那里无所谓
3:void PxInt0(void) interrupt 0 中断名为PxInt0的0号中断
void PxInt1(void) interrupt 2 中断名为PxInt1的2号中断
void time0_int(void) interrupt 1 中断名为time0_int的1号中断
void time1_int(void) interrupt 3 中断名为time1_int的3号中断
4:中断的代码是你想中断执行的工作,中断的代码是根据任务,需要你自己写的