<?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>nRF91: UART async read</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59586/nrf91-uart-async-read</link><description>Hi, 
 What is the best way to read the async data received on a UART in to a buffer when ever there is an a byte available and in a separate task read the data from the buffer as and when needed. 
 reards 
 KK</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Mar 2020 14:32:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59586/nrf91-uart-async-read" /><item><title>RE: nRF91: UART async read</title><link>https://devzone.nordicsemi.com/thread/242138?ContentTypeID=1</link><pubDate>Fri, 27 Mar 2020 14:32:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92cd63de-0e20-4b1c-82c5-834a81893ef9</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi KK,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That should be fine.&amp;nbsp;The documentation even lists uart reception as one of the main use-cases:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/other/ring_buffers.html"&gt;https://docs.zephyrproject.org/latest/reference/kernel/other/ring_buffers.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;H&amp;aring;kon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF91: UART async read</title><link>https://devzone.nordicsemi.com/thread/242137?ContentTypeID=1</link><pubDate>Fri, 27 Mar 2020 14:26:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4d01d8c-0fc8-4a5b-ba3c-20c8133e81df</guid><dc:creator>kk2mkk</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;Mean while i have figured it out the way you suggested in your first link, but i am ring_buf_put() to collect byte by byte in ISR call back and in task i use ring_buf_get() to get the data when ever needed, i hope ring_buf_put() is not bulky to use in ISR?&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;KK&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF91: UART async read</title><link>https://devzone.nordicsemi.com/thread/242102?ContentTypeID=1</link><pubDate>Fri, 27 Mar 2020 13:17:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab571502-c277-44fc-9f7a-876992e2d41f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For receiving uart data byte-for-byte, you can set up your project similar to this:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/uart/src/main.c"&gt;https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/uart/src/main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But, I would recommend that you do as little processing as possible in the UART interrupt handler, by for instance passing the data to a &lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/data_passing/fifos.html"&gt;FIFO&lt;/a&gt; or using a &lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/threads/workqueue.html#system-workqueue"&gt;system workqueue&lt;/a&gt;, or which ever other method you prefer.&lt;/p&gt;
&lt;p&gt;If you require more advance uart handling (with RX timeouts, specific sizes, etc), I would recommend that you look into the uart_async module. There&amp;#39;s a test-program for it here, which includes several uses of it:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-zephyr/tree/master/tests/drivers/uart/uart_async_api"&gt;https://github.com/NordicPlayground/fw-nrfconnect-zephyr/tree/master/tests/drivers/uart/uart_async_api&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>