<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC Microcontrollersのトピックuart_rom_int example-- Transmit callback called too early</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/uart-rom-int-example-Transmit-callback-called-too-early/m-p/577276#M19575</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by jdupre on Tue Oct 06 16:05:15 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to modify the uart_rom_int example for the LPC15xx to work with an RS-485 transceiver.&amp;nbsp;&amp;nbsp; To start, I simply added functions to enable/disable the transceiver's TxEnable line to the putLineUART() function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;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
&amp;nbsp;&amp;nbsp; transfer is complete */
param.callback_func_pt = (UART_CALLBK_T) waitCallback;

/* Transmit the data using interrupt mode, the function will
&amp;nbsp;&amp;nbsp; return */
gotCallback = false;

TxEnable();/* Enable Tx on RS-485 transceiver */

if (LPC_UARTD_API-&amp;gt;uart_put_line(uartHandle, &amp;amp;param)) {
errorUART();
}

/* Wait until the transmit callback occurs. When it hits, the
&amp;nbsp;&amp;nbsp; transfer is complete. */
sleepUntilCB();

TxDisable();/* Disable Tx on RS-485 transceiver */
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TxEnable goes high before calling uart_put_line, and then should go low after the callback is called.&amp;nbsp; The callback is supposed to indicate that the UART has completed sending all characters, correct?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I am observing that the callback system is indicating transmission is complete _before_ it is actually complete.&amp;nbsp; (See the attached screen shot of the data capture.) TxEnable is going low BEFORE the final two characters '\r' and '\n' are sent.&amp;nbsp; How is this possible?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is probably more of an issue with the LPC15xx UART API, but I thought I'd ask here as a sanity check.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:17:06 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:17:06Z</dc:date>
    <item>
      <title>uart_rom_int example-- Transmit callback called too early</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/uart-rom-int-example-Transmit-callback-called-too-early/m-p/577276#M19575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by jdupre on Tue Oct 06 16:05:15 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to modify the uart_rom_int example for the LPC15xx to work with an RS-485 transceiver.&amp;nbsp;&amp;nbsp; To start, I simply added functions to enable/disable the transceiver's TxEnable line to the putLineUART() function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;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
&amp;nbsp;&amp;nbsp; transfer is complete */
param.callback_func_pt = (UART_CALLBK_T) waitCallback;

/* Transmit the data using interrupt mode, the function will
&amp;nbsp;&amp;nbsp; return */
gotCallback = false;

TxEnable();/* Enable Tx on RS-485 transceiver */

if (LPC_UARTD_API-&amp;gt;uart_put_line(uartHandle, &amp;amp;param)) {
errorUART();
}

/* Wait until the transmit callback occurs. When it hits, the
&amp;nbsp;&amp;nbsp; transfer is complete. */
sleepUntilCB();

TxDisable();/* Disable Tx on RS-485 transceiver */
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TxEnable goes high before calling uart_put_line, and then should go low after the callback is called.&amp;nbsp; The callback is supposed to indicate that the UART has completed sending all characters, correct?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I am observing that the callback system is indicating transmission is complete _before_ it is actually complete.&amp;nbsp; (See the attached screen shot of the data capture.) TxEnable is going low BEFORE the final two characters '\r' and '\n' are sent.&amp;nbsp; How is this possible?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is probably more of an issue with the LPC15xx UART API, but I thought I'd ask here as a sanity check.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/uart-rom-int-example-Transmit-callback-called-too-early/m-p/577276#M19575</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:06Z</dc:date>
    </item>
  </channel>
</rss>

