<?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>Half-duplex UART (single wire) with and two nRF52840-DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65783/half-duplex-uart-single-wire-with-and-two-nrf52840-dk</link><description>I&amp;#39;m trying to achieve half-duplex UART communication between two nRF52840-DK:s (master/slave) using no external circuitry. I was looking at the thread https://devzone.nordicsemi.com/f/nordic-q-a/15513/nrf52832-single-wire-uart where the OP had a similar</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Sep 2020 13:52:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65783/half-duplex-uart-single-wire-with-and-two-nrf52840-dk" /><item><title>RE: Half-duplex UART (single wire) with and two nRF52840-DK</title><link>https://devzone.nordicsemi.com/thread/269015?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 13:52:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cd41777-3ff7-4b0c-b317-db8942359dd9</guid><dc:creator>TSonono</dc:creator><description>&lt;p&gt;Thanks Jorgen, that fixed&amp;nbsp;my problem, and the communication between the DK:s now works in half-duplex.&lt;br /&gt;&lt;br /&gt;For anyone trying to do&amp;nbsp;accomplish something similar, keep in mind that the flag might have to be volatile&amp;nbsp;if you wait for the flag in your main context and modify it in the handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Half-duplex UART (single wire) with and two nRF52840-DK</title><link>https://devzone.nordicsemi.com/thread/268938?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 11:30:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40f175e5-e79e-4000-97e4-259f2f7d1407</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You need to first un-initialize the uart library using&amp;nbsp;&lt;a title="app_uart_close" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__app__uart.html?cp=7_1_6_10_57_10#gabcee6fffee8cafe5bea28f5496c6847b"&gt;app_uart_close&lt;/a&gt;(). The&amp;nbsp;APP_UART_FIFO_INIT() macro will initialize the UART driver. If you call this macro again without first un-initializing the driver, it will report that it is already initialized and give you an error.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not 100% sure if the close-function will wait for any events that has lower or equal IRQ priority to the one in&amp;nbsp;uart_error_handle(). It is safer to set a flag in the handler and do the re-initialization in the main context.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Half-duplex UART (single wire) with and two nRF52840-DK</title><link>https://devzone.nordicsemi.com/thread/268932?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 11:03:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8e5320a-9536-4aa2-9679-82543b900a33</guid><dc:creator>TSonono</dc:creator><description>&lt;p&gt;Hi J&amp;ouml;rgen,&lt;/p&gt;
&lt;p&gt;Thanks for the swift reply.&lt;/p&gt;
&lt;p&gt;I just tried your suggestion,&amp;nbsp;where it currently looks like this:&lt;br /&gt;&lt;br /&gt;Master:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void init_uart(uint32_t rx_pin, uint32_t tx_pin);

void uart_error_handle(app_uart_evt_t * p_event)
{
    if (p_event-&amp;gt;evt_type == APP_UART_COMMUNICATION_ERROR)
    {
        APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
    }
    else if (p_event-&amp;gt;evt_type == APP_UART_FIFO_ERROR)
    {
        APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
    }
    else if (p_event-&amp;gt;evt_type == APP_UART_TX_EMPTY)
    {
        init_uart(27, UART_PIN_DISCONNECTED);
        NRF_LOG_DEBUG(&amp;quot;TX Empty&amp;quot;);
    }
}

static void init_uart(uint32_t rx_pin, uint32_t tx_pin)
{
    uint32_t err_code;

    const app_uart_comm_params_t comm_params =
    {
        rx_pin,
        tx_pin,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        APP_UART_FLOW_CONTROL_DISABLED,
        false,
#if defined(UART_PRESENT)
        NRF_UART_BAUDRATE_115200
#else
        NRF_UARTE_BAUDRATE_115200
#endif
    };

    APP_UART_FIFO_INIT(&amp;amp;comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_error_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);
}

int main(void)
{
    .
    .
    .
    init_uart(UART_PIN_DISCONNECTED, 27);
    
    uint8_t cr = 5;
    NRF_LOG_INFO(&amp;quot;Sent char %d&amp;quot;, cr);
    while (app_uart_put(cr) != NRF_SUCCESS);
    nrf_delay_ms(2500);
    
    while (app_uart_get(&amp;amp;cr) != NRF_SUCCESS);
    nrf_delay_ms(2500);
    NRF_LOG_INFO(&amp;quot;Received char %d\r\n&amp;quot;, cr);
    .
    .
    .
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This results in a fatal error from APP_ERROR_CHECK in init_uart(). Should I not be re-initializing app_uart in the&amp;nbsp;UART event handler?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Half-duplex UART (single wire) with and two nRF52840-DK</title><link>https://devzone.nordicsemi.com/thread/268893?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 09:19:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f560ac7-b819-4bc5-8836-0322d3d4b86e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I do not think that the UART peripheral will work correctly if you set both TX and RX pin to the same GPIO. You should rather set the RX pin to &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__app__uart.html#gaa790ff39126a00c4308f30f1139f4efa"&gt;UART_PIN_DISCONNECTED&lt;/a&gt;&amp;nbsp;initially and switch&amp;nbsp;the pins after transmitting the data, by re-initializing the UART library. If you have a 2500 ms delay, there should be plenty of time to do this. You can use the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__app__uart.html#gga9346b21b144fd9499e24853bbf781e17a9fa032c57eadcef66e102eb78a04c2d1"&gt;APP_UART_TX_EMPTY&lt;/a&gt;&amp;nbsp;event to determine when it is safe to reinit the library.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>