void Openint(void) //打开中断
{
EA=1;//开中断
IT0=1; //外部中断0下降沿触发
IT1=1; //外部中断1下降沿触发
EX0=1;//外部中断0
EX1=1;//外部中断1
ET0=1;//开timer0中断
ES=0;//开串口中断
}
void IntGradeSet(void) //设置优先级
{
PS=0; //串口优先级
PT0=0; //timer0中断优先级
PT1=0; //timer1中断优先级
PX0=0; //int0中断优先级
PX1=0; //int1中断优先级
}
{
EA=1;//开中断
IT0=1; //外部中断0下降沿触发
IT1=1; //外部中断1下降沿触发
EX0=1;//外部中断0
EX1=1;//外部中断1
ET0=1;//开timer0中断
ES=0;//开串口中断
}
void IntGradeSet(void) //设置优先级
{
PS=0; //串口优先级
PT0=0; //timer0中断优先级
PT1=0; //timer1中断优先级
PX0=0; //int0中断优先级
PX1=0; //int1中断优先级
}
void UARTint(void) interrupt 4 using 3 //串口中断处理
{
uchar receivr_buffer;
TI=0; //很重要,否则会一直进中断处理程序的!
EA=0;
if(RI==1)
{
RI=0;
receivr_buffer = SBUF;
if (point == 0)
{
if (receivr_buffer == 0xa5)
IDChageRx[point++] = receivr_buffer;
//point++;
else point = 0;
}
else if (point>0 && point<4)
IDChageRx[point++] = receivr_buffer;
else
{
point = 0;
IDChageRx[0]=0;
IDChageRx[1]=0;
IDChageRx[2]=0;
IDChageRx[3]=0;
}
}
EA=1;
}
{
uchar receivr_buffer;
TI=0; //很重要,否则会一直进中断处理程序的!
EA=0;
if(RI==1)
{
RI=0;
receivr_buffer = SBUF;
if (point == 0)
{
if (receivr_buffer == 0xa5)
IDChageRx[point++] = receivr_buffer;
//point++;
else point = 0;
}
else if (point>0 && point<4)
IDChageRx[point++] = receivr_buffer;
else
{
point = 0;
IDChageRx[0]=0;
IDChageRx[1]=0;
IDChageRx[2]=0;
IDChageRx[3]=0;
}
}
EA=1;
}