<?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>UART interrupt missing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55402/uart-interrupt-missing</link><description>Hello, 
 
 I am using SDK SDK_15.3.0_59ac345 with soft device in application that controls a GPS IC from UART (AT command), also the application is running in background beacon adv. (timeslot) and from time to time ble normal adv and gatt connection etc</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 04 Feb 2020 09:16:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55402/uart-interrupt-missing" /><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/232479?ContentTypeID=1</link><pubDate>Tue, 04 Feb 2020 09:16:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdb5d5bf-077a-41e5-98f5-2a6fcd57a99f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;issue created&amp;nbsp;NRFFOSDK-13129&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/229159?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2020 08:32:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b383f529-1f7d-4291-9ec5-fc6218f9af6c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I have now tested this myself extensively and I was now able to reproduce this myself. I am going to create an internal ticket that it was a bug before and the suggested fix and I will close this case.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/225888?ContentTypeID=1</link><pubDate>Tue, 17 Dec 2019 13:11:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30d2bd7c-65cd-4598-9809-35a0f913909a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Sure Carlos, I will keep this ticket open as a reminder to myself until I can update you in the future.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/225627?ContentTypeID=1</link><pubDate>Mon, 16 Dec 2019 12:35:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f505a92f-3064-4406-a30c-22c74fcd8465</guid><dc:creator>Carlos</dc:creator><description>&lt;p&gt;Thanks Susheel! :-)&lt;/p&gt;
&lt;p&gt;From our side, on the extensive testing of the patch during these days we could not reproduce again this problem and could not find any side effect so we applied this change.&lt;/p&gt;
&lt;p&gt;If finally, your developement team confirm this changer or find a better solution or any any possible side effect I appreciate you can update the ticket. Thank you.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/225537?ContentTypeID=1</link><pubDate>Mon, 16 Dec 2019 07:40:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cee50d75-f922-4f78-a2c5-79e92f1f2a94</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;sorry for the late reply, it seems you are right, I did some experimenting in nrfx_uart.c and it seems that clearing the RXDRDY event in rx_enable creates a race condition. Not clearing it seems to solve the issue. I will forward this behavior to the developer team.&lt;/p&gt;
[quote user="ca.itech"]I am a bit lost but I am sure you can check this better than me![/quote]
&lt;p&gt;You don&amp;#39;t seem to be lost, seems to have good understanding on the nrfx_uart :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/224791?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2019 16:54:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0e843f7-987c-46aa-8023-8717bc4a7115</guid><dc:creator>Carlos</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;I am using Nordic SDK code as it is for uart, and the&amp;nbsp;&lt;span&gt;nrf_drv_uart_rx&amp;nbsp;I think is called by event_handler in app_uart_fifo.c and not by my code.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The only thing I am doing is calling init using the macro I copied in top of this case:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;APP_UART_FIFO_INIT(&amp;amp;comm_params,&lt;br /&gt;UART_RX_BUF_SIZE,&lt;br /&gt;UART_TX_BUF_SIZE,&lt;br /&gt;uart_event_handle,&lt;br /&gt;&lt;strong&gt;APP_IRQ_PRIORITY_HIGHEST,&lt;/strong&gt;&lt;br /&gt;err_code);&lt;br /&gt;APP_ERROR_CHECK(err_code);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And in my uart_event_handle in case of&amp;nbsp;APP_UART_DATA_READY just get data from&amp;nbsp;app_uart_get()&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The code running below is Nordic&amp;#39;s original code.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Therefore, in my checking the app_uart_init() in app_uart_fifo.c install the handler with the priority&amp;nbsp;&lt;strong&gt;APP_IRQ_PRIORITY_HIGHEST&lt;/strong&gt; and this is the code which is calling to&amp;nbsp;nrf_drv_uart_rx() every&amp;nbsp;NRF_DRV_UART_EVT_RX_DONE event after it adds data to the fifo and call to&amp;nbsp;my handler.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then going down,&amp;nbsp;nrfx_uart_init() in nrfx_uart.c is the function that install uart fifo event handler together with the&amp;nbsp;nrfx_uart_0_irq_handler&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;nrfx_uart_0_irq_handler()-&amp;gt;uart_irq_handler()-&amp;gt;rx_byte()-&amp;gt;nrf_uart_event_clear()+&lt;strong&gt;nrf_uart_rxd_get&lt;/strong&gt;()-&amp;gt;rx_done_event()-&amp;gt;call fifo handler that calls to&amp;nbsp;nrf_drv_uart_rx&amp;nbsp;()-&amp;gt;&lt;strong&gt;rx_enable&lt;/strong&gt;()-&amp;gt;&lt;span style="text-decoration:underline;"&gt;&lt;em&gt;nrf_uart_event_clear(NRF_UART_EVENT_RXDRDY)&lt;/em&gt;&lt;/span&gt; again that is the one deleted by my test&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I do not clear the NRF_UART_EVENT_RXDRDY in&amp;nbsp;rx_enable() seems to be everthing working fine and therefore the only possibility is that the UART task which sets&amp;nbsp;NRF_UART_EVENT_RXDRDY to 1 is called between&amp;nbsp;&lt;strong&gt;nrf_uart_rxd_get()&lt;/strong&gt; and&amp;nbsp;&lt;strong&gt;rx_enable()&amp;nbsp;&lt;/strong&gt;interrumping the interrupt.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;I am a bit lost but I am sure you can check this better than me!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/224766?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2019 14:14:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0f4e870-c24e-455c-9c76-621d172d2003</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="ca.itech"]Just after every interrupt of Rx the uart_event_handler in app_uart_fifo.c driver restart by&amp;nbsp;calling&amp;nbsp;nrf_drv_uart_rx() to read a new byte, at this point the function will call to rx_enable that clears the RXDRDY bit without checking if it has been already raised by a new interrupt. I think this is wrong, in normal environment the delay from processing the interrupt till&amp;nbsp;&lt;span&gt;nrf_drv_uart_rx() is may be very few but with cpu overload could be the case that new uart byte arrived from interrupt process ends till a new call to&amp;nbsp;nrf_drv_uart_rx is done (115200bps and cpu overload), if this happens then the RXDRDY may be cleared and then a new interrupt is not generated... This is my guess&amp;nbsp;&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;You are onto something here. Let me try to explain you the flow. The RXRDY EVENT is not set by the interrupt, it is the other way around. The UART sets this event bit first which infact is communicated to ARM-&amp;gt;NVIC.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Well I think you are calling&amp;nbsp;&lt;span&gt;nrf_drv_uart_rx from a context that is higher in priority than the UART ISR priority. Otherwise the context that called&amp;nbsp;nrf_drv_uart_rx should not continue from the instant a new RXRDY_EVENT is pended. Can you please confirm from which context you are calling the RX function? I cannot see any other possible scenario that the&amp;nbsp;nrf_drv_uart_rx&amp;nbsp;function is able to clear a new pended event bit.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If&amp;nbsp;nrf_drv_uart_rx&amp;nbsp;is called from lower priority context (than UART_ISR priority) then it will be without question only be able to clear a processed RXRDY bit&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/224742?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2019 13:05:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9df394b4-e181-4ba2-b633-16b7f7a5001e</guid><dc:creator>Carlos</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;I understood your suggestions, thank you for checking.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In the meantime I was trying to check places where&amp;nbsp;&lt;span&gt;RXDRDY is cleared. I found a possible problem however I am not sure about the structure of your driver.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I remove clearing the&amp;nbsp;RXDRDY in&amp;nbsp;rx_enable() function in nrfx_uart.c I cannot reproduce the problem, I have been checking long time and could not reproduce it again, additionally I removed all log and set original enviroment and also could not reproduce the problem. I would need more time to fully check but it is very significative because without this change problem can be reproduced easilly when activating ble paring (flash write inside) and beacon timeslot together with uart and now cannot reproduce it after several hours of trying.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;My guess:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Just after every interrupt of Rx the uart_event_handler in app_uart_fifo.c driver restart by&amp;nbsp;calling&amp;nbsp;nrf_drv_uart_rx() to read a new byte, at this point the function will call to rx_enable that clears the RXDRDY bit without checking if it has been already raised by a new interrupt. I think this is wrong, in normal environment the delay from processing the interrupt till&amp;nbsp;&lt;span&gt;nrf_drv_uart_rx() is may be very few but with cpu overload could be the case that new uart byte arrived from interrupt process ends till a new call to&amp;nbsp;nrf_drv_uart_rx is done (115200bps and cpu overload), if this happens then the RXDRDY may be cleared and then a new interrupt is not generated... This is my guess&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Additionally, I think this call to clear RXDRDY here is not necessary because it is already done when received last byte inside interrupt before reading as specs says. In fact, without this call my software is working fine now, however I don&amp;#39;t know all possible test cases and why this was introduced.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Would you please review my suggestion?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Change:&lt;/p&gt;
&lt;p&gt;static void rx_enable(nrfx_uart_t const * p_instance)&lt;br /&gt; {&lt;br /&gt;nrf_uart_event_clear(p_instance-&amp;gt;p_reg, NRF_UART_EVENT_ERROR);&lt;br /&gt;- nrf_uart_event_clear(p_instance-&amp;gt;p_reg, NRF_UART_EVENT_RXDRDY);&lt;br /&gt;+// nrf_uart_event_clear(p_instance-&amp;gt;p_reg, NRF_UART_EVENT_RXDRDY);&lt;br /&gt; nrf_uart_task_trigger(p_instance-&amp;gt;p_reg, NRF_UART_TASK_STARTRX);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/224712?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2019 11:50:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08789574-44f0-4446-97ca-5d297992c56a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I am not sure we can trust those logs 100%.&lt;/p&gt;
&lt;p&gt;Normally there are latencies to flush the log from the time NRF_LOG_INFO is being called. And during that time, the real state in the register might have changed.&lt;/p&gt;
&lt;p&gt;I would suggest you to do two things.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set a breakpoint in nrfx_uart.c&amp;nbsp;-&amp;gt;&amp;nbsp;uart_irq_handler-&amp;gt; inside the if condition which is executed if there is&amp;nbsp;NRF_UART_EVENT_ERROR set.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Start your program in debugger mode, and try to repeat this error condition. If you notice the delay in reply is more than it should then halt/pause the execution (do not stop the debugger or reset the device, but halt the state to retain hardware state). At this point check if the RXRDY register bit is still set.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If the breakpoint from 1. is hit, then we know that the error handling is something that you would like to handle differently. Inside nrf_log_backend_uart.c the&amp;nbsp;uart_evt_handler shows that the error is simple ignored, which for some application could be a issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/224452?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2019 13:18:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f17eae4-f49e-4b83-b000-1a784d7162ac</guid><dc:creator>Carlos</dc:creator><description>&lt;p&gt;It is APP_UART_FLOW_CONTROL_ENABLED&lt;/p&gt;
&lt;p&gt;Baud is&amp;nbsp;NRF_UART_BAUDRATE_115200&lt;/p&gt;
&lt;p&gt;PIN numbers are default ones&lt;/p&gt;
&lt;p&gt;and buffers size is 512&lt;/p&gt;
&lt;p&gt;These are the missing values.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Flow control I am sure it is working because as I explained even waiting 150ms the data is there and it is not lost and I can follow reading next character without any missing one means that other ic is waiting to send more characters till I read. The problem is that rxrdy is not raised.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART interrupt missing</title><link>https://devzone.nordicsemi.com/thread/224446?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2019 13:10:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32cf7325-9a76-46c2-bcc9-719c8e3d559b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;.flow_control = eFlow,&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What is the value of eFlow here? if it is false, then there is a possibility that there are some overflow errors in the driver that are not handled. For testing purposes, I would recommend to enable flow control just to confirm that it is infact an overflow error in the driver.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>