<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>RS485 transmit enable</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46911/rs485-transmit-enable</link><description>We&amp;#39;re running a multi-drop single duplex RS485 bus, so it&amp;#39;s important to stop driving the bus as soon as a transmit is complete so the next device can transmit without two drivers driving the bus at once. Is there a way to set up hardware control of the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 04 May 2019 11:10:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46911/rs485-transmit-enable" /><item><title>RE: RS485 transmit enable</title><link>https://devzone.nordicsemi.com/thread/185286?ContentTypeID=1</link><pubDate>Sat, 04 May 2019 11:10:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac116025-f498-4a09-ae5d-2dc99544f02b</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;See also the duplicate thread:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/46912/rs485-transmit-enable"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/46912/rs485-transmit-enable&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RS485 transmit enable</title><link>https://devzone.nordicsemi.com/thread/185261?ContentTypeID=1</link><pubDate>Fri, 03 May 2019 19:55:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd7bae54-238a-4320-94cf-eea0e4f72487</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;There is no hardware control I know of, but you can use &lt;em&gt;APP_UART_TX_EMPTY&lt;/em&gt;, which indicates &amp;quot;&lt;em&gt;All Sent&lt;/em&gt;&amp;quot; similar to other devices. This could be linked to the driver control pin via PPI, but here is the interrupt version:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  // Set up RS485 Driver Enable output pin
  nrf_gpio_pin_clear(PIN_RS485_DE);
  nrf_gpio_cfg_output(PIN_RS485_DE);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is the serial port interrupt&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint16_t index = 0;
    uint32_t ret_val;

    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:          // Event UART data received. The data is available in the FIFO and can be fetched using @ref app_uart_get
            // blah-blah
            break;

        case APP_UART_COMMUNICATION_ERROR: // Error has occured during reception. The error is stored in app_uart_evt_t.data.error_communication field
            NRF_LOG_ERROR(&amp;quot;Communication error occurred while handling UART.&amp;quot;);
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:          // Error in FIFO module used by the app_uart module has occured. The FIFO error code is stored in app_uart_evt_t.data.error_code field
            NRF_LOG_ERROR(&amp;quot;Error occurred in FIFO module used by UART.&amp;quot;);
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        case APP_UART_TX_EMPTY:            // Event UART has completed transmission of all available data in the TX FIFO
            // Disable RS485 differential driver
            nrf_gpio_pin_clear(PIN_RS485_DE);
            break;

        case APP_UART_DATA:                // Event UART data has been received, and data is present in data field. This event is only used when no FIFO is configured
        default:
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Assuming packets are sent from a single function, here is the transmit enable:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void SendViaHardwareUart(char * InfoPacket)
{
    uint32_t err_code;
    uint32_t txIndex;

    // Hardware uart can be disabled to save power and extend battery life
    if (HardwareUartEnabled)
    {
        // Enable RS485 differential driver
        nrf_gpio_pin_set(PIN_RS485_DE);
        // blah-blah
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>