<?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 and I2C conflict on nrf51 with S130</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15514/uart-and-i2c-conflict-on-nrf51-with-s130</link><description>I am working on application where the nrf51 will read information from several sensors and send the data to a smartphone app via BLE. Among the sensors are one that sends a 23 byte message via UART at 9600 Baud about once a second and an Si7021 temp/humidity</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Aug 2016 09:08:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15514/uart-and-i2c-conflict-on-nrf51-with-s130" /><item><title>RE: UART and I2C conflict on nrf51 with S130</title><link>https://devzone.nordicsemi.com/thread/59242?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2016 09:08:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ca31d7a-7f27-453d-b2a4-bd3170f1c698</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;You don’t need to send the uart handler (I assume you mean the code inside the handler) to main context using scheduler, unless you do a lot of stuff inside the handler of course, then you should put that code in a function and send it to main context using the scheduler.&lt;/p&gt;
&lt;p&gt;About the overrun error handler you should not call app_uart_flush(), this will flush the software fifo (created in app_uart_fifo.c) not the UART peripheral fifo. You can call app_uart_flush() if you get fifo error (APP_UART_FIFO_ERROR), but in that case you should consider allocating a bigger fifo (UART_RX_BUF_SIZE).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART and I2C conflict on nrf51 with S130</title><link>https://devzone.nordicsemi.com/thread/59241?ContentTypeID=1</link><pubDate>Thu, 04 Aug 2016 02:30:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d40b830a-cabb-4c9b-8c39-5c17417fd987</guid><dc:creator>machineherder</dc:creator><description>&lt;p&gt;Right now, I have left the above UART handler as is without using the scheduler to send it to main context.  I expect that, even though the blocking TWI commands are going to a higher interrupt context behind the scenes, UART handler can now jump in any time between these blocking commands, which is probably the right behavior.&lt;/p&gt;
&lt;p&gt;Is there any sense in sending the UART handler to main context using scheduler?  It appears that app_timer_appsh is sending the entire timeout routine to main context as one event, so that would defeat the purpose, right?  Or is there some way to make scheduler do the right thing?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART and I2C conflict on nrf51 with S130</title><link>https://devzone.nordicsemi.com/thread/59240?ContentTypeID=1</link><pubDate>Thu, 04 Aug 2016 02:24:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22fa1bd2-1311-4425-9b16-1cbdd70438a2</guid><dc:creator>machineherder</dc:creator><description>&lt;p&gt;Thanks, Ole, I implemented app_scheduler for the entire timeout using the convenient app_timer_appsh library, and now I can have the TWI code running in the timeout routine (now running in main context,) and dump a ton of text to the UART without overrun.  I want to do some more testing on this approach, but I&amp;#39;ll come back and ratify your answer if it looks ok.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d still like to handle any potential UART over runs gracefully- my code above for the error handler seems to work, any feedback as to any other housekeeping I need to do at that point?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART and I2C conflict on nrf51 with S130</title><link>https://devzone.nordicsemi.com/thread/59239?ContentTypeID=1</link><pubDate>Wed, 03 Aug 2016 12:46:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:751e01a9-7e38-47d2-bbd0-c69834c55b69</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;If you get overrun error it indicates that you are blocking the uart interrupt for more than 6 bytes (the error will happen if the UART peripheral FIFO is full and a start bit is detected on the bus). With 9600 baud this is (using 8N2 -&amp;gt; 10 bauds per byte) 60 / 9600 * 1000 = 6.25ms. It will actually be a bit more since there is some time between every byte.&lt;/p&gt;
&lt;p&gt;The TWI transaction you are doing within the interrupt may take too long time and be the reason you get overrun errors. I suggest that you try to use app_scheduler to run the code from main context. I recommend to read &lt;a href="https://devzone.nordicsemi.com/tutorials/23"&gt;this&lt;/a&gt; tutorial on app_scheduler. You can also set up app_timer to execute the handlers in main context using app_scheduler.&lt;/p&gt;
&lt;p&gt;Generally speaking you should spend as little time as possible inside interrupts, or else things like this can happen.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>