Tool/software:
Hello,
I am using Uart2 for communication.
I am facing issue while sending the data form dl_uart_transmitdatablocking function.
Sometimes the data from the buffer is not send completly on the uart.
The data from buffer is also seen in UART2_TXDATA register and FIFOs are also enabled. (Uart Baudrate 9600)
following is the code for your reference. I have also attached screenshot of TX data available in the buffer to send and data received in the external terminal(docklight).
void UartSendSlave(UARTFIFODATA * uart) {
Uint16 TxPtr = 0;
datacntptr=0;
do {
/*if (MAP_UARTSpaceAvail(uart->base)) {
MAP_UARTCharPutNonBlocking(uart->base, uart->buff[TxPtr]);
TxPtr++;
} else {
// sleep the task for a while
OS_DELAY(1);
*/
/* DL_UART_transmitData(uart->base, uart->buff[TxPtr]);
TxPtr++;*/
// TxPtr=uart->buff[datacntptr];
DL_UART_transmitDataBlocking(uart->base,uart->buff[datacntptr]);
datacntptr++;
} while (datacntptr < uart->txcnt);
}
/****************************************************
* FUNCTION: UartSlaveExecute
*
* PARAMETERS:UARTFIFODATA * uart
*
* DESCRIPTION: called in loop by process when slave is active
*
****************************************************/
void UartSlaveExecute(UARTFIFODATA *uart)
{
if (uart->mode != U_SLAVE)
return;
switch (uart->status)
{
case U_TX:
case U_WAIT:
uart->status = U_WAIT;
uart->rxcnt = 0;
//Wait forever here for a new message
if (OS_SEMAPHORE_TAKE( uart->SemUartRXstart, OS_MAX_DELAY ) != pdTRUE)
{
//OS_DELAY(1);
return;
}
case U_RX:
//Loop until packet complete ( no more chars for some time )
//Packet complete , analyze
uart->status = U_TX;
uart->protocol_func(uart);
//If there is a response , send it
if (uart->txcnt)
{
// OS_DELAY(1);
//Set 485 direction (only if defined, for half/duplex)
if (uart->tx_en_port != 0)
{
if (uart->base == (unsigned long) MB_SLV_B_INST)
{
TxEnable(uart);
}
else
{
TxEnable2(uart);
}
}
//Fifo mode for transmit
DL_UART_enableFIFOs(uart->base);
//Send packet and wait for transmission to complete ( sem given by TX interrupt)
UartSendSlave(uart);
if (OS_SEMAPHORE_TAKE( uart->SemUartTXend, 30 ) == pdFALSE)
{
}
while (DL_UART_isBusy(uart->base));
// while (DL_UART_isBusy(uart->base));
// it's now safe to put the transceiver back in RX mode . N.B.: now done in TX interrupt
}
uart->status = U_WAIT;
uart->txcnt = 0;
break;
case U_ERR:
uart->rxcnt = 0;
uart->txcnt = 0;
uart->status = U_WAIT;
OS_DELAY(1);
break;
}
}