<?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>Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88892/unexpected-rxdrdy-count</link><description>Hello, 
 I&amp;#39;m writing my own UARTE library because I need some functionality not offered in the SDK. But I came across a hardware behaviour I can&amp;#39;t explain. 
 In my understanding, the RXDRDY event is triggered when a byte is fully received in the RX pin</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 13 Oct 2022 09:00:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88892/unexpected-rxdrdy-count" /><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/390581?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2022 09:00:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5695f6db-01c9-4663-b562-40ed5983a545</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Again, my apologies for the slow feedback on this request. I was able to reproduce the issue and received some feedback from our HW team on when the event is generated.&lt;/p&gt;
&lt;p&gt;The RXDRDY event is generated every time a byte is moved to the top of the FIFO. This means that for the first 16 bytes, the data will be moved to RAM and the a new byte will me placed at the top of the FIFO when it is received. When the 17th byte is received, this will also be stored at the top of the FIFO and a RXDRDY event will be generated. However, since the RAM buffer is full (MAXCNT reached), the byte will be left in the FIFO until the UARTE is flushed/restarted. If you receive more data after the 17th byte, these bytes will be placed lower in the FIFO, and the RXDRDY events will first be generated when the data at the top of the FIFO is moved to RAM and a new byte is moved to&amp;nbsp;the top of the FIFO.&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><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/375602?ContentTypeID=1</link><pubDate>Tue, 05 Jul 2022 14:30:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:732c7ad0-22eb-4b65-bfa9-645581383c23</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi, sorry for the slow response. Yes, I have received the project and I&amp;#39;m working on reproducing the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/374922?ContentTypeID=1</link><pubDate>Thu, 30 Jun 2022 13:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6d2c972-50f7-4cc2-a33a-44c01506860e</guid><dc:creator>Marco</dc:creator><description>&lt;p&gt;Hello &lt;a href="https://devzone.nordicsemi.com/members/joh2"&gt;Jørgen Holmefjord&lt;/a&gt;&amp;nbsp;, just checking if you received the project.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/374017?ContentTypeID=1</link><pubDate>Thu, 23 Jun 2022 16:55:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7ea955c-4655-48c0-b739-0e4691d1f78f</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;It is possible that something like that is happening, but there is one RXDRDY event generated after ENDRX in your logic traces.&lt;/p&gt;
&lt;p&gt;Please send the project as a zip file in a private message to me. Alternatively, I can convert this case to private.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/374008?ContentTypeID=1</link><pubDate>Thu, 23 Jun 2022 15:25:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de6ddd69-46b3-4252-b70d-cc6a8f2773f2</guid><dc:creator>Marco</dc:creator><description>&lt;p&gt;Is it possible that&amp;nbsp;on ENDRX an internal clock is stopped and that causes the RXDRDY event to not trigger until it&amp;#39;s restarted?&lt;/p&gt;
&lt;p&gt;I can send you the source code privately if you provide an email address.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/373754?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2022 15:10:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbc4d7bf-77ea-4328-96d2-86be7cdb6861</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;According to our HW team, the RXDRDY event should be generated after the STOP bit(s) as long as there is no OVERRUN error.&lt;/p&gt;
&lt;p&gt;Can you provide code and instructions to reproduce this behavior? We would need to see the exact conditions to be able to&amp;nbsp;check it further.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/373525?ContentTypeID=1</link><pubDate>Tue, 21 Jun 2022 16:24:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0da25336-0d04-4c0b-a729-40d35c7fdfe3</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Thank you for providing the traces. I have forwarded your findings to our HW team, to see if they can answer when the RXDRDY event is generated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/373160?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2022 07:58:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db26acfd-813d-4768-88e7-ba8cfa4fc809</guid><dc:creator>Marco</dc:creator><description>&lt;p&gt;In my understanding, the ENDRX is triggered on MAXCNT, not MAXCNT-4. The 4 extra bytes can be stored in the RX FIFO.&lt;/p&gt;
&lt;p&gt;Anyway, my concern are the RXDRDY events. The specs say&lt;/p&gt;
&lt;p&gt;&lt;em&gt;For each byte received over the RXD line, an RXDRDY event will be generated.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;and the timing diagrams suggest that the event is raised immediately after a byte is received. My testing shows that the last RXDRDY event can be delayed until the UARTE is restarted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/373095?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 16:32:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c534772d-882a-4437-9c33-a5215b7c81ab</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Interesting issue; since the first ENDRX is generated after 19 bytes which implies AMOUNT is correct assuming the stop was triggered by hitting MAXCOUNT minus the 4 bytes due to use of flow control so is the MAXCNT = 23? That first ENDRX was not issued by hitting the timeout. My interpretation is that the unexpected ENDRX count is correct depending on latency of interrupt generation:&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;em&gt;If the ENDRX event has not already been generated when the UARTE receiver has&lt;/em&gt;&lt;br /&gt;&lt;em&gt;come to a stop, which implies that all pending content in the RX FIFO has been moved to the RX&lt;/em&gt;&lt;br /&gt;&lt;em&gt;buffer, the UARTE will generate the ENDRX event explicitly even though the RX buffer is not full. In&lt;/em&gt;&lt;br /&gt;&lt;em&gt;this scenario the ENDRX event will be generated before the RXTO event is generated&lt;/em&gt;.&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/373086?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 15:44:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca544895-b457-4554-acfb-60bee12b2c83</guid><dc:creator>Marco</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/joh2"&gt;Jørgen Holmefjord&lt;/a&gt; Here&amp;#39;s a capture with the events, as requested. GPIOTE is set to toggle the pins when the event occours.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/2080x1866/__key/communityserver-discussions-components-files/4/2110.Capture1.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Zoomed:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/2080x1886/__key/communityserver-discussions-components-files/4/3108.Capture2.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In this example:&lt;/p&gt;
&lt;p&gt;21 bytes are received in the first block, but AMOUNT is 19 and RXDRDY count is 20. You can see that there was no RXDRDY event for the last byte. Instead, the RXDRDY for that byte occurs immediately before reasserting RTS. Here&amp;#39;s a zoomed view:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/2080x1860/__key/communityserver-discussions-components-files/4/6327.Capture3.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/373041?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 12:58:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cadeba93-f39e-45e5-923f-26f51a621207</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Would you be able to output the events (RXDRDY, RXTO, END,&amp;nbsp;COMPARE event) on GPIOs, to read out with the logic analyzer how the events are generated compared to your incoming data and task triggering? You can PPI and GPIOTE to setup this.&lt;/p&gt;
&lt;p&gt;Also, if you can provide a minimal example that can be used to reproduce the behavior you are seeing, that would help us give you a better answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/372712?ContentTypeID=1</link><pubDate>Thu, 16 Jun 2022 07:20:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d1f3efe-17f1-42c6-9468-b4b7a97fdb4c</guid><dc:creator>Marco</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/joh2"&gt;Jørgen Holmefjord&lt;/a&gt; Any update on this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/372434?ContentTypeID=1</link><pubDate>Tue, 14 Jun 2022 15:50:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db6e984b-9fc7-4960-a0e2-a7ed185f6790</guid><dc:creator>Marco</dc:creator><description>&lt;p&gt;Here&amp;#39;s the relevant code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    //Configure RX count timer
    nrfx_timer_config_t tmr_config_count = NRFX_TIMER_DEFAULT_CONFIG;
    tmr_config_count.mode = NRF_TIMER_MODE_COUNTER;
    tmr_config_count.p_context = (void *)p_serial;
    ret = nrfx_timer_init(p_serial-&amp;gt;p_timer_rxcount, &amp;amp;tmr_config_count, timer_rxcount_evt_handler);
    if (ret != NRFX_SUCCESS)
        return NRF_ERROR_INTERNAL;
    nrfx_timer_enable(p_serial-&amp;gt;p_timer_rxcount);

    //Configure RX timeout timer
    nrfx_timer_config_t tmr_config_timeout = NRFX_TIMER_DEFAULT_CONFIG;
    tmr_config_timeout.frequency = NRF_TIMER_FREQ_1MHz;
    tmr_config_timeout.p_context = (void *)p_serial;
    ret = nrfx_timer_init(p_serial-&amp;gt;p_timer_rxtimeout, &amp;amp;tmr_config_timeout, timer_rxtimeout_evt_handler);
    if (ret != NRFX_SUCCESS)
        return NRF_ERROR_INTERNAL;
    nrfx_timer_compare(p_serial-&amp;gt;p_timer_rxtimeout, NRF_TIMER_CC_CHANNEL0, p_config-&amp;gt;timeout_us, false);

    // ...
    
    //  When a byte is received, increment RX count timer
    PPI_CH_SETUP(p_serial-&amp;gt;p_ctrl_blk-&amp;gt;ppi_channels[SERIALPORT_PPI_CH_0],
                 nrf_uarte_event_address_get(p_serial-&amp;gt;uarte, NRF_UARTE_EVENT_RXDRDY),
                 nrfx_timer_task_address_get(p_serial-&amp;gt;p_timer_rxcount, NRF_TIMER_TASK_COUNT),
                 NULL);
    //  When a byte is received, restart RX timeout timer
    PPI_CH_SETUP(p_serial-&amp;gt;p_ctrl_blk-&amp;gt;ppi_channels[SERIALPORT_PPI_CH_1],
                 nrf_uarte_event_address_get(p_serial-&amp;gt;uarte, NRF_UARTE_EVENT_RXDRDY),
                 nrfx_timer_task_address_get(p_serial-&amp;gt;p_timer_rxtimeout, NRF_TIMER_TASK_START),
                 nrfx_timer_task_address_get(p_serial-&amp;gt;p_timer_rxtimeout, NRF_TIMER_TASK_CLEAR));
    //  On RX timeout timer compare, stop it and stop UART RX
    PPI_CH_SETUP(p_serial-&amp;gt;p_ctrl_blk-&amp;gt;ppi_channels[SERIALPORT_PPI_CH_2],
                 nrfx_timer_compare_event_address_get(p_serial-&amp;gt;p_timer_rxtimeout, 0),
                 nrfx_timer_task_address_get(p_serial-&amp;gt;p_timer_rxtimeout, NRF_TIMER_TASK_STOP),
                 nrf_uarte_task_address_get(p_serial-&amp;gt;uarte, NRF_UARTE_TASK_STOPRX));
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When the RX timeout timer compares, it triggers the STOPRX task on the UARTE.&lt;/p&gt;
&lt;p&gt;My RXTO irq handler then reads the RXD.AMOUNT register and the value of the other timer which I use to count the RXDRDY events.&lt;/p&gt;
&lt;p&gt;On that image, no more bytes are sent when the RTS is deasserted.&lt;/p&gt;
&lt;p&gt;No, I don&amp;#39;t trigger FLUSHRX. If there&amp;#39;s extra data in the RX FIFO, I&amp;#39;m fine with it being read when I setup the next DMA transaction, but I need to know if there&amp;#39;s data there so I can manually restart the RX timeout timer. I need to do that because I manually stop the RX timeout timer at the beginning of the RXTO handler. Which, in turn, I do because the RX timeout timer is stopped by PPI on the RX timeout timer Compare event, but up to 4 extra bytes could be received, and those RXDRDY events would make PPI restart the RX timer.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a bit mind-bending, I hope that makes sense.&lt;/p&gt;
&lt;p&gt;But I just want to know when the RXDRDY event is triggered. It appears it&amp;#39;s not when the stop bit is received at the RX pin, like the docs suggest.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected RXDRDY count</title><link>https://devzone.nordicsemi.com/thread/372430?ContentTypeID=1</link><pubDate>Tue, 14 Jun 2022 15:05:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14355566-867f-41ec-b800-d1f59a91925a</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you post your code showing how you configure the timer to count the events, and how you do the timeout?&lt;/p&gt;
&lt;p&gt;Hard to see from your image, but is any of the bytes sent right after the RTS line is deactivated? The UART(E) peripheral has a HW RX FIFO that can hold up to 4 bytes, as described in the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/uarte.html#concept_uzb_p2m_wr"&gt;peripheral documentation&lt;/a&gt;. Do you trigger the STOPRX and/or FLUSHRX task at any point?&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>