lpcware

uart_rom_int example-- Transmit callback called too early

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by jdupre on Tue Oct 06 16:05:15 MST 2015
I'm trying to modify the uart_rom_int example for the LPC15xx to work with an RS-485 transceiver.   To start, I simply added functions to enable/disable the transceiver's TxEnable line to the putLineUART() function:

static void putLineUART(const char *send_data)
{
UART_PARAM_T param;

param.buffer = (uint8_t *) send_data;
param.size = strlen(send_data);

/* Interrupt mode, do not append CR/LF to sent data */
param.transfer_mode = TX_MODE_SZERO;
param.driver_mode = DRIVER_MODE_INTERRUPT;

/* Setup the transmit callback, this will get called when the
   transfer is complete */
param.callback_func_pt = (UART_CALLBK_T) waitCallback;

/* Transmit the data using interrupt mode, the function will
   return */
gotCallback = false;

TxEnable();/* Enable Tx on RS-485 transceiver */

if (LPC_UARTD_API->uart_put_line(uartHandle, &param)) {
errorUART();
}

/* Wait until the transmit callback occurs. When it hits, the
   transfer is complete. */
sleepUntilCB();

TxDisable();/* Disable Tx on RS-485 transceiver */
}


TxEnable goes high before calling uart_put_line, and then should go low after the callback is called.  The callback is supposed to indicate that the UART has completed sending all characters, correct?

However, I am observing that the callback system is indicating transmission is complete _before_ it is actually complete.  (See the attached screen shot of the data capture.) TxEnable is going low BEFORE the final two characters '\r' and '\n' are sent.  How is this possible?

This is probably more of an issue with the LPC15xx UART API, but I thought I'd ask here as a sanity check. 

Outcomes