void UART0_Interrupt (void) interrupt 4
{
if (RI0 == 1)
{
str1 = str0;
str0 = SBUF0;
if ((str0 == 0x09) && (str1 == 0x7e) && (biao == 0)) //帧头判断
{
str_IN[0] = str1;
str_IN[1] = str0;
biao = 1;
str_L = 1;
}
if (biao == 1) //&& (str_L < 7))
{
str_IN[str_L] = str0;
str_L++;
}
if ((biao == 1) && (str_L >= 6) && (str_IN[str_L-1] == 0x7e)) //接收结束完毕
{
str_IN[str_L] = str0;
biao = 0;
str_L = 0;
TX_Ready = 1;//接收完毕标志位
}
if((biao == 1) && (str_L > 7))
{
biao = 0;
str_L = 0;
}
RI0 = 0; //接收中断标志位
}
TI0=0;
}
|