Hi Xiangjun,
Thanks for your reply, i test the code you send me, but found it always output "K" after install the callback function, the callback function should only output one char "K" at one time, i also only do count++ in the call back, but found it will not stop to call the callback, it never to stop. My another colleague also encounter this issue.
So i dive into the driver layer code carefully, found it would be one bug in driver lay, it needs to add the two line red code, as below is the code in TX interrupt in fsl_uart_driver.c, if i install the TX callback function by UART_DRV_InstallTxCallback function, the code will never move the position of TXbuffer and transfer byte numbers, so it lead to never to call UART_DRV_CompleteSendData(instance);
Now after i add these two line, the code can work as expected. do you think so? (one remainder, don't forget to build the lib after you change the fsl_uart_driver.c file)
if((UART_BRD_C2_TIE(base)) && (UART_BRD_S1_TDRE(base)))
{
/* Check to see if there are any more bytes to send */
if (uartState->txSize)
{
uint8_t emptyEntryCountInFifo;
#if FSL_FEATURE_UART_HAS_FIFO
emptyEntryCountInFifo = uartState->txFifoEntryCount -
UART_HAL_GetTxDatawordCountInFifo(base);
#else
emptyEntryCountInFifo = uartState->txFifoEntryCount;
#endif
while(emptyEntryCountInFifo--)
{
/* Transmit data and update tx size/buff */
UART_HAL_Putchar(base, *(uartState->txBuff));
/* Invoke callback if there is one */
if (uartState->txCallback != NULL)
{
/* The callback MUST set the txSize to 0 if the
* transmit is ended.*/
uartState->txCallback(instance, uartState);
++uartState->txBuff;
--uartState->txSize;
}
else
{
++uartState->txBuff;
--uartState->txSize;
}
/* Check and see if this was the last byte */
if (uartState->txSize == 0U)
{
UART_DRV_CompleteSendData(instance);
break;
}
}
}