u8 conhandlePC=0;
//------------------------------------------
void SearchPC(void) { u8 temp; u8 countbyte=0; while(Uart3.RxOut != Uart3.RxIn)//命令没有查询到头 { temp = Uart3.RxBuffer[Uart3.RxOut]; Uart3.RxOut = (Uart3.RxOut + 1) & UART2RXBUFFERLENGTH; switch(conhandlePC) { case 0:if( AscK(temp)) conhandlePC=1;else conhandlePC=0;break; case 1:if( AscA(temp)) conhandlePC=2;else conhandlePC=0;break; case 2:if( AscB(temp)) conhandlePC=3;else conhandlePC=0;break; case 3:if( Asc0(temp)) conhandlePC=4;else conhandlePC=0;break; case 4:if( Asc0(temp)) conhandlePC=5;else conhandlePC=0;break; case 5:if( Asc1(temp)) conhandlePC=6;else conhandlePC=0;break; case 6:if( AscR(temp)) conhandlePC=7;else {countbyte=0;conhandlePC=8;PutCharToUart1Single('W');}break; case 7:{ Read001(); Uart3.RxOut=Uart3.RxIn; conhandlePC=0; break; } case 8: { if(countbyte>21) { countbyte=0; conhandlePC=0; break; } else { PutCharToUart1Single(temp); countbyte++; conhandlePC=8; break; } } default :conhandlePC=0;break; } } } //----------------------------------
每次复位后我通过串口助手发送KAB001+23个字节,但是执行完后conhandlePC=8,而不是等于0!还有,如果我把u8 countbyte=0;放在全局变量处,程序就死在void HardFaultException(void)处。想不明白,请高手指点迷津啊 |