<?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>Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59560/shutting-down-uarte-cleanly-stuck-at-nrf_uarte_event_txstopped</link><description>I need a UARTE driver that does a few things differently to the provided UARTE driver and hence I am writing my own based on nrfx_uarte.c . At the moment I am testing the code which initialises and deinitialises my driver: no data transmission or reception</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 06 Apr 2020 12:14:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59560/shutting-down-uarte-cleanly-stuck-at-nrf_uarte_event_txstopped" /><item><title>RE: Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/thread/243630?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2020 12:14:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f018a34a-f641-4479-9fe7-93af9059d9de</guid><dc:creator>RobMeades</dc:creator><description>&lt;p&gt;Right, I have it working now.&amp;nbsp; There were two problems:&lt;/p&gt;
&lt;p&gt;1. It helps if you enable the UARTE :-).&amp;nbsp; I had&amp;nbsp;&lt;strong&gt;nrf_uarte_int_enable()&lt;/strong&gt; but didn&amp;#39;t also have &lt;strong&gt;nrf_uarte_enable()&lt;/strong&gt;.&amp;nbsp; However, that alone didn&amp;#39;t fix it...&lt;/p&gt;
&lt;p&gt;2. My Tx is always blocking, so I handle &lt;strong&gt;TX_STOP&lt;/strong&gt; etc. in my send routine.&amp;nbsp; But I&amp;#39;d also OR&amp;#39;ed the Tx events into the interrupt enable.&amp;nbsp; I had to take the Tx events &lt;em&gt;out&lt;/em&gt; of the bitmask given to &lt;strong&gt;nrf_uarte_int_enable()&lt;/strong&gt;&amp;nbsp;then everything behaves.&lt;/p&gt;
&lt;p&gt;Phew, at last.&amp;nbsp; Thanks for trying to help me with this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/thread/243434?ContentTypeID=1</link><pubDate>Fri, 03 Apr 2020 14:42:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65f9a578-4acd-434c-bbd0-b3413d727d77</guid><dc:creator>RobMeades</dc:creator><description>&lt;p&gt;Well, replacing what I have in &lt;strong&gt;main_test.c&lt;/strong&gt; with what&amp;#39;s in that example&amp;#39;s &lt;strong&gt;main.c&lt;/strong&gt; certainly works in that it doesn&amp;#39;t get stuck on&amp;nbsp;&lt;strong&gt;NRF_UARTE0-&amp;gt;EVENTS_TXSTOPPED&lt;/strong&gt;, it flows through and ends up in the &lt;strong&gt;while()&lt;/strong&gt; loop at the end. So what &lt;em&gt;am&lt;/em&gt; I doing wrong?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/thread/243272?ContentTypeID=1</link><pubDate>Thu, 02 Apr 2020 20:57:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c61234d-7f85-4807-8ff9-7b687d5d1181</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I am currently looking into it. I attached a logic analyzer to look at the TX pin, and I noticed that nothing was being sent at all.&lt;/p&gt;
&lt;p&gt;I also saw that the event&amp;nbsp;&lt;span style="font-weight:400;"&gt;EVENTS_TXSTARTED did not happen either, thus the call to&amp;nbsp;&lt;em&gt;nrf_uarte_task_trigger(.. NRF_UARTE_STARTTX)&amp;nbsp;&lt;/em&gt;has no effect.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;I will investigate more tomorrow.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;However, &lt;a href="https://github.com/andenore/NordicSnippets/tree/master/examples/uart"&gt;here&lt;/a&gt; is a nice bare-metal example that demonstrates, on a register level, how to configure UARTE and transmit a message. It might be nice to use it as a reference. Just copy the content of main.c into your projects main.c&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/thread/243268?ContentTypeID=1</link><pubDate>Thu, 02 Apr 2020 19:58:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abc133ad-9cbc-4605-9f01-a0697f338269</guid><dc:creator>RobMeades</dc:creator><description>&lt;p&gt;Any insights?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/thread/242802?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2020 23:05:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f63642ae-1ba0-46fe-832e-736896e68bd9</guid><dc:creator>RobMeades</dc:creator><description>&lt;p&gt;Thanks: I&amp;#39;m sure it is something stupid that I&amp;#39;ve [not] done, appreciate your help.&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/thread/242797?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2020 21:45:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e23d35d-3adb-4487-8561-c279c5b5057e</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Strange...&amp;nbsp; I will take a look at it tomorrow.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/thread/242667?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2020 11:15:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed07234d-ca02-41ef-b436-e8a618430217</guid><dc:creator>RobMeades</dc:creator><description>&lt;p&gt;I&amp;#39;ve update the post above to include a ZIP file that contains a standalone build, a single source file, showing what I&amp;#39;m doing.&amp;nbsp; If you run it in the debugger you can see that I initialise &lt;strong&gt;UARTE0&lt;/strong&gt; and then attempt to transmit a few bytes through it.&amp;nbsp; The code stops at the line where I&amp;#39;m waiting for&amp;nbsp;&lt;strong&gt;NRF_UARTE_EVENT_TXSTOPPED&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;I must be doing something really basic wrong: can you see what?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/thread/242320?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 08:53:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ea55dea-e8f2-447b-8e89-e560b039a9d3</guid><dc:creator>RobMeades</dc:creator><description>&lt;p&gt;Interesting changes but I&amp;#39;m not sure they have helped in my case.&amp;nbsp; As you will see from the code above, I have a buffer within my driver code which is set up to receive&amp;nbsp;constantly (&lt;strong&gt;gUartData[uart].rxBuffer.pBufferStart&lt;/strong&gt;) from the point that&amp;nbsp; my init() function is called, so there is always reception on-going.&amp;nbsp; Hence the code at your link:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;    if (p_cb-&amp;gt;handler)
    {
        interrupts_disable(p_instance);
    }
    // Make sure all transfers are finished before UARTE is disabled
    // to achieve the lowest power consumption.
    nrf_uarte_shorts_disable(p_reg, NRF_UARTE_SHORT_ENDRX_STARTRX);

    // Check if there is any ongoing reception.
    if (p_cb-&amp;gt;rx_buffer_length)
    {
        nrf_uarte_event_clear(p_reg, NRF_UARTE_EVENT_RXTO);
        nrf_uarte_task_trigger(p_reg, NRF_UARTE_TASK_STOPRX);
    }

    nrf_uarte_event_clear(p_reg, NRF_UARTE_EVENT_TXSTOPPED);
    nrf_uarte_task_trigger(p_reg, NRF_UARTE_TASK_STOPTX);

    // Wait for TXSTOPPED event and for RXTO event, provided that there was ongoing reception.
    while (!nrf_uarte_event_check(p_reg, NRF_UARTE_EVENT_TXSTOPPED) ||
           (p_cb-&amp;gt;rx_buffer_length &amp;amp;&amp;amp; !nrf_uarte_event_check(p_reg, NRF_UARTE_EVENT_RXTO)))
    {}

    nrf_uarte_disable(p_reg);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;...reduces to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    nrf_uarte_int_disable(pReg, NRF_UARTE_INT_ENDRX_MASK |
                                NRF_UARTE_INT_ENDTX_MASK |
                                NRF_UARTE_INT_ERROR_MASK |
                                NRF_UARTE_INT_RXTO_MASK  |
                                NRF_UARTE_INT_TXSTOPPED_MASK);
    NRFX_IRQ_DISABLE(nrfx_get_irq_number((void *) (pReg)));
    
    // Make sure all transfers are finished before UARTE is
    // disabled to achieve the lowest power consumption
    nrf_uarte_shorts_disable(pReg, NRF_UARTE_SHORT_ENDRX_STARTRX);
    nrf_uarte_event_clear(pReg, NRF_UARTE_EVENT_RXTO);
    nrf_uarte_task_trigger(pReg, NRF_UARTE_TASK_STOPRX);
    nrf_uarte_event_clear(pReg, NRF_UARTE_EVENT_TXSTOPPED);
    nrf_uarte_task_trigger(pReg, NRF_UARTE_TASK_STOPTX);
    while (!nrf_uarte_event_check(pReg, NRF_UARTE_EVENT_TXSTOPPED) ||
           !nrf_uarte_event_check(pReg, NRF_UARTE_EVENT_RXTO)) {}
    
    // Disable the UARTE
    nrf_uarte_disable(pReg);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;...which still gets stuck for me at that &lt;strong&gt;while&lt;/strong&gt;() statement.&lt;br /&gt;&lt;br /&gt;So that you can see the full picture, my entire driver (without these latest changes above) is visible here:&lt;br /&gt;&lt;br /&gt;&lt;a href="https://github.com/u-blox/cellular/blob/master/port/platform/nordic/nrf52840/src/cellular_port_uart.c"&gt;https://github.com/u-blox/cellular/blob/master/port/platform/nordic/nrf52840/src/cellular_port_uart.c&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Can you see anything else that I&amp;#39;m doing wrong, or have I somehow misunderstood the intention of the changes?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Shutting down UARTE cleanly, stuck at NRF_UARTE_EVENT_TXSTOPPED</title><link>https://devzone.nordicsemi.com/thread/242258?ContentTypeID=1</link><pubDate>Sun, 29 Mar 2020 21:01:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85d078e5-f3b3-424e-bf22-d1589b8b45bb</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Some changes were recently made to the NRFX drivers which&amp;nbsp;I think will fix your problem:&amp;nbsp;&lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/master/CHANGELOG.md"&gt;https://github.com/NordicSemiconductor/nrfx/blob/master/CHANGELOG.md&lt;/a&gt;&lt;/p&gt;
&lt;div style="padding-left:30px;"&gt;&lt;em&gt;&amp;quot;Improved the UARTE driver to consume less current after the driver uninitialization. Now all clocks are disabled properly after uninitialization.&amp;quot;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Check it out &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/281cc2e178fd9a470d844b3afdea9eb322a0b0e8/drivers/src/nrfx_uarte.c#L306"&gt;here&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&lt;hr /&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards,&lt;/div&gt;
&lt;div&gt;Simon&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>