This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

串口波特率9600异常

芯片:2530

协议栈:3.0.2

问题:我在用自定义的串口配置的时候,出现了一些异常;我的串口回调函数是把串口接收到的数据原样写出去,当我配置波特率为19200或者9600的时候,30个字节的数据会出现丢失一半以上的数据,9600波特率的时候甚至没有输出,我在回调里面设置断点发现没有输出的时候没有进入到串口的回调函数。这个问题当我配置的波特率高于38400的时候就不会出现,前提是enddevice,使能了power saving以及 zTool_P1,在APP层初始化的时候osal_pwrmgr_device( PWRMGR_ALWAYS_ON );请问高手这是什么情况呢?我该怎么解决,谢谢。串口配置如下。

void UserUsartInit(void)
{
    halUARTCfg_t uartConfig;
    uartConfig.configured           = TRUE;
    uartConfig.baudRate             = HAL_UART_BR_9600;
    uartConfig.flowControl          = FALSE;
    uartConfig.flowControlThreshold = HAL_UART_FLOW_THRESHOLD;
    uartConfig.rx.maxBufSize        = 128;
    uartConfig.tx.maxBufSize        = 128;
    uartConfig.idleTimeout          = 6;
    uartConfig.intEnable            = TRUE;
    uartConfig.callBackFunc         = npUartCback;
    HalUARTOpen(HAL_UART_PORT, &uartConfig);
}

static void npUartCback(uint8 port, uint8 event)
{
  switch (event) {
  case HAL_UART_RX_FULL:
  case HAL_UART_RX_ABOUT_FULL:
  case HAL_UART_RX_TIMEOUT:
       process_mt_msg(port, zclGenericApp_TaskID); 
    break;

  case HAL_UART_TX_EMPTY:

    break;

  default:
    break;
  }
}

uint8 process_mt_msg( uint8 port, uint8 event )
{
    uint8  msg_length=0;
    uint8  zbuf[50] = {0};

    msg_length = Hal_UART_RxBufLen(port);
    if(msg_length) 
    {
        HalUARTRead(port,zbuf, msg_length);
    }
    
    HalUARTWrite( 0, zbuf, msg_length );
    osal_set_event( zclGenericApp_TaskID, LED_SHORT_BLINK_EVT );

    return 1;
}