Hi Community,
Please help me for below issue.
Following line sending only first letter K 5 times.
unsigned char str[] = "Kumar Rishi\r\n";
UART_DRV_SendData(UART0_IDX, str, 5);
Function:
uart_status_t UART_DRV_SendData(uint32_t instance, const uint8_t * txBuff,
uint32_t txSize)
{
assert(txBuff);
assert(instance < UART_INSTANCE_COUNT);
uart_status_t retVal = kStatus_UART_Success;
uart_state_t * uartState = (uart_state_t *)g_uartStatePtr[instance];
/* Indicates current transaction is non-blocking */
uartState->isTxBlocking = false;
/* Start the transmission process */
retVal = UART_DRV_StartSendData(instance, txBuff, txSize);
return retVal; }
static uart_status_t UART_DRV_StartSendData(uint32_t instance, const uint8_t * txBuff,
uint32_t txSize)
{
assert(instance < UART_INSTANCE_COUNT);
UART_Type * base = g_uartBase[instance];
uart_state_t * uartState = (uart_state_t *)g_uartStatePtr[instance];
/* Check that we're not busy already transmitting data from a previous
* function call. */
if (uartState->isTxBusy)
{
return kStatus_UART_TxBusy;
}
if (txSize == 0U)
{
return kStatus_UART_NoDataToDeal;
}
/* Initialize the module driver state structure. */
uartState->txBuff = txBuff;
uartState->txSize = txSize;
uartState->isTxBusy = true;
/* Enable the transmitter data register empty interrupt. The TDRE flag will
* set whenever the TX buffer is emptied into the TX shift register (for
* non-FIFO IPs) or when the data in the TX FIFO is at or below the
* programmed watermark (for FIFO-supported IPs). */
UART_BWR_C2_TIE(base, 1U);
return kStatus_UART_Success;
}
Hello Ashish Singh:
Is your issue resolved?
As mentioned by Alice, you can use the KSDK UART example projects as starting point, either the blocking or non-blocking examples:
C:\Freescale\KSDK_1.3.0\examples\frdmk64f\driver_examples\uart
If you still face issues after checking the examples please share your project so I can have a look and see what you are missing.
Regards!
Jorge Gonzalez
Hello Singh,
I checked you use the KSDK.
Please use the function of "UART_DRV_SendDataBlocking" to send a sting .
A blocking (also known as synchronous) function means that the function does
not return until the transmit is complete.
While the function UART_DRV_SendData ,
means that the function
* returns immediately after initiating the transmit function. The application
* has to get the transmit status to see when the transmit is complete. In
* other words, after calling non-blocking (asynchronous) send function, the
* application must get the transmit status to check if transmit is completed
* or not.
This meaning in the period of send data , if something else occur , the send will be some error,
for example some interrupt occur . So , please use the function of "UART_DRV_SendDataBlocking".
About the usage of this function , please refer to the demo code at here :
KSDK_1.3.0\examples\frdmk64f\driver_examples\uart\uart_blocking
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------