<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-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://test-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 Non-Production</generator><lastBuildDate>Thu, 16 Jun 2022 07:20:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/88892/unexpected-rxdrdy-count" /><item><title>RE: Unexpected RXDRDY count</title><link>https://test-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>user69773</dc:creator><description>&lt;p&gt;&lt;a href="https://test-devzone.nordicsemi.com/members/user14926"&gt;user14926&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://test-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>user69773</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://test-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>user14926</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>