打印

奇怪的问题,好几天了想不明白!请教高手!

[复制链接]
1734|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
很夏天|  楼主 | 2008-10-27 09:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
pc, AN, EPC, se, TE
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)处。想不明白,请高手指点迷津啊
沙发
很夏天|  楼主 | 2008-10-27 09:49 | 只看该作者

补充一下:

我的目的是从串口3读到数据后转发给串口1,串口三有两种数据格式,包头一样KAB001,后面的字节分两种,一种是READ1,一种是W+22个字节;

本以为很简单,没想到出了这样的问题,我是第一次用STM32,还不知到好不好用啊

使用特权

评论回复
板凳
yangbo_zd| | 2008-10-27 11:39 | 只看该作者

STM32肯定好用

HardFaultException
是硬件错误,是不是哪里溢出了?

使用特权

评论回复
地板
很夏天|  楼主 | 2008-10-27 17:51 | 只看该作者

问题解决了

问题解决了,莫名奇妙的又好了,还是要谢谢楼上的关注俺们新手

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

22

帖子

0

粉丝