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.

串口读取数据后,再调用串口输出数据函数没有反应

Other Parts Discussed in Thread: CC2530, Z-STACK

使用Z-Stack Energy 1.1.0进行开发时,想通过串口调试助手向CC2530协调器发送数据后,协调器立即将收到的数据发送至串口调试助手,但是发现串口可以收到数据但是不能调用发送数据至串口调试助手,接收使用的是自己写的回调函数,如下:

void MT_UartInit ()
{
halUARTCfg_t uartConfig;

/* Initialize APP ID */
App_TaskID = 0;

/* UART Configuration */
uartConfig.configured = TRUE;
//uartConfig.baudRate = MT_UART_DEFAULT_BAUDRATE;
uartConfig.baudRate = HAL_UART_BR_115200;
#ifdef ZNP_UART_TEST
uartConfig.flowControl = FALSE;
#else
uartConfig.flowControl = TRUE;
#endif
uartConfig.flowControlThreshold = MT_UART_DEFAULT_THRESHOLD;
uartConfig.rx.maxBufSize = MT_UART_DEFAULT_MAX_RX_BUFF;
uartConfig.tx.maxBufSize = MT_UART_DEFAULT_MAX_TX_BUFF;
uartConfig.idleTimeout = MT_UART_DEFAULT_IDLE_TIMEOUT;
uartConfig.intEnable = TRUE;
#if defined (ZTOOL_P1) || defined (ZTOOL_P2)
//uartConfig.callBackFunc = MT_UartProcessZToolData;
uartConfig.callBackFunc = rxCB;
#elif defined (ZAPP_P1) || defined (ZAPP_P2)
uartConfig.callBackFunc = MT_UartProcessZAppData;
#else
uartConfig.callBackFunc = NULL;
#endif

/* Start UART */
#if defined (MT_UART_DEFAULT_PORT)
HalUARTOpen (MT_UART_DEFAULT_PORT, &uartConfig);
#else
/* Silence IAR compiler warning */
(void)uartConfig;
#endif

/* Initialize for ZApp */
#if defined (ZAPP_P1) || defined (ZAPP_P2)
/* Default max bytes that ZAPP can take */
MT_UartMaxZAppBufLen = 1;
MT_UartZAppRxStatus = MT_UART_ZAPP_RX_READY;
#endif

}

回调函数如下:

void rxCB( uint8 port, uint8 event )
{

uint8 rxlen;
uint8 databuf[128];
rxlen=Hal_UART_RxBufLen(port);

if (rxlen)
{
HalUARTRead (port, databuf, rxlen);
HalUARTWrite ( port, "Received!", 9 );

}

}

请问HalUARTWrite为什么不能正常发送? 

ps:如果在HalUARTRead (port, databuf, rxlen);后重新打开串口,HalUARTOpen,设置新的uartConfig,HalUARTWrite就又能够向调试助手发送数据了,HalUARTWrite在使用前一定要重新打开串口吗?