<?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>nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91343/nrf5340-uart-interrupt-mode-send-example</link><description>Hi all!
I&amp;#39;m currently working on the UART on the nRF5340 board. The SDK describes three options: -polling API,
-interrupt-driven API,
-asynchronous API. With Polling and Asynchronous - everything is clear and they do not suit me for various reasons. Interrupt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 20 Sep 2022 12:48:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91343/nrf5340-uart-interrupt-mode-send-example" /><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/387077?ContentTypeID=1</link><pubDate>Tue, 20 Sep 2022 12:48:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d8623f7-6765-4b72-89fa-eb94f7be5143</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;You welcome Sergey.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The best of luck with your project &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/386775?ContentTypeID=1</link><pubDate>Mon, 19 Sep 2022 07:38:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb5dbbf8-f413-4abd-bbaa-8d3258790e88</guid><dc:creator>SergeySK</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi&amp;nbsp;&lt;/span&gt;&lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;thanks for answers!&lt;/p&gt;
&lt;pre id="tw-target-text" class="tw-data-text tw-text-large tw-ta" dir="ltr"&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;Best regards, Sergey.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/386630?ContentTypeID=1</link><pubDate>Fri, 16 Sep 2022 11:58:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70909019-9de9-431b-b27b-0145580f6afe</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Sergey&lt;/p&gt;
&lt;p&gt;Whether or not you use DMA this is a result of the asynchronous nature of UART communication.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You need some kind of algorithm on the receiving side that goes through the incoming bytes one by one, and figures out what is the start and end of each packet, before the packet is sent to the application for processing.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The only difference is whether each RX callback could contain 1 or multiple bytes. In the case of DMA you might get multiple bytes at once, which means you need to loop through each one and run the packetization algorithm&amp;nbsp;like mentioned above.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/386182?ContentTypeID=1</link><pubDate>Wed, 14 Sep 2022 12:46:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad1c7347-82d4-4481-b76a-75b92e980a5e</guid><dc:creator>SergeySK</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi&amp;nbsp;&lt;/span&gt;&lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;&lt;br /&gt;Of course, a double buffer is also a very good solution and of course I use it, but if the packets go one after the other, then two packets appear in one buffer, and often the packet is located simultaneously in two buffers, which is not very convenient.&lt;br /&gt;&lt;span&gt;Best regards, Sergey.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/385663?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2022 09:13:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b950512-ccf5-400e-80ae-3888295bc9f9</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Sergey&lt;/p&gt;
&lt;p&gt;Thanks for explaining the issue in more detail.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The way we handle this issue using EasyDMA (and the issue of buffer overrun in general) is to make the DMA pointer double buffered. Once you have configured the first buffer through the RXD.PTR register (or by using a higher level driver to do the same), and started the RX reception, you can then proceed to write a second buffer to the RXD.PTR register.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As soon as the first buffer fills up the hardware peripheral will seamlessly switch to the second buffer, meaning you can continue receiving without any gap in the communication.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On completion of the first buffer you will get an interrupt from the peripheral, allowing you to set up the third buffer while the second buffer is being filled up. And so on.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Based on the UART baudrate used and the number and length of interrupts in your system you can scale the RX buffers to ensure that an overrun will never happen.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/385507?ContentTypeID=1</link><pubDate>Fri, 09 Sep 2022 11:43:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b4e83a4-f167-4631-8e26-3e686f88aa6b</guid><dc:creator>SergeySK</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Of course, transferring between internal devices via DMA is preferable, but specifically with UART this can cause problems.&lt;br /&gt; &lt;br /&gt;Let me explain with an example: if you need to receive a packet of 8 bytes, and set DMA to 8 bytes, then the impulse noise, &amp;quot;lowering&amp;quot; the RxD line for the time of the start bit, will ruin everything, and the false byte will be received first, then the 7th will be received byte of the packet, and the 8th byte will be lost.&lt;br /&gt;&lt;br /&gt;And when using STX / ETX, the length of the packets can vary greatly due to the replacement of codes, and programming the DMA length will be a problem.&lt;br /&gt;&lt;br /&gt;p.s. EazyDMA is a great idea!&lt;br /&gt;&lt;br /&gt;Best regards, Sergey.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/385449?ContentTypeID=1</link><pubDate>Fri, 09 Sep 2022 08:40:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2bc8d1c-cfa3-48e7-883c-ed986dd945c8</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Sergey&lt;/p&gt;
&lt;p&gt;DMA is just a different way to transfer data to and from a peripheral to RAM, and unless you transfer the data to RAM you won&amp;#39;t be able to do anything with it.&lt;/p&gt;
&lt;p&gt;Most of the peripherals in the nRF5340 uses DMA, including the radio, crypto modules, ADC and serial interfaces, so if the simple act of using DMA would cause a lot of data corruption it would be apparent immediately.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In fact it is a bit imprecise of me to say that the async driver utilizes DMA, since all the UART drivers have to use the DMA feature to transfer data. The difference is that the async driver allows you to scale the RX buffers as you like (up to a maximum of 2^16 bytes) rather than process a single byte at a time, which means it utilizes the DMA feature in a more efficient way.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In some of our older devices like the nRF52832 there was a UART peripheral without DMA controller, but this peripheral was deprecated and removed in newer devices.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/385339?ContentTypeID=1</link><pubDate>Thu, 08 Sep 2022 14:21:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95c53efb-860d-4d25-a1ee-de0f7758f93e</guid><dc:creator>SergeySK</dc:creator><description>&lt;p&gt;Hi&lt;br /&gt;It is impossible to use DMA for reception in the real world, since in it (the real world) you can both lose a byte due to interference, and get +1 0xFF byte due to an interference pulse (start bit 0).&lt;br /&gt;And in wearable devices, it is quite easy to be near a thyristor regulator, a neon lamp or a contactless charger, and indeed there is a lot of interference in the real world.&lt;br /&gt;Best regads&lt;br /&gt;Sergey.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/385236?ContentTypeID=1</link><pubDate>Thu, 08 Sep 2022 11:06:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10a78680-64c3-4c4c-b245-8ebd82776dd1</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;The async driver also utilizes the DMA feature of the UARTE peripheral to avoid generating interrupts on every single byte. You need to provide buffers for the UART driver to use, and the larger you make the buffers the more rare the interrupts will be.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/384745?ContentTypeID=1</link><pubDate>Tue, 06 Sep 2022 09:13:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f6b3daf-7458-40ce-a643-40a85a2df0b3</guid><dc:creator>SergeySK</dc:creator><description>&lt;p&gt;Thanks for the tip, Torbjorn.&lt;br /&gt;I guessed that for the first byte it is proposed to use blocking output, and all subsequent ones through the ring buffer is a classic.&amp;nbsp;&lt;br /&gt;And UART interrupts load the processor with noise much less, for example, when waiting for the start byte (STX), the rest are simply ignored.&lt;br /&gt;Best regads!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/384505?ContentTypeID=1</link><pubDate>Mon, 05 Sep 2022 08:19:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:feea87cf-2456-45a3-8db1-adb108c77ce4</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Sergii&lt;/p&gt;
&lt;p&gt;Sigurd is currently unavailable, and I will help you with this case in the mean time.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any particular reason why the async driver would not be suitable? If you are handling a lot of communication this should be more efficient.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The hci_uart sample in Zephyr uses the interrupt driver both in TX and RX, and you can have a look at that to see how you can handle the TX part in the interrupt. In particular have a look at &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/samples/bluetooth/hci_uart/src/main.c#L207-L245"&gt;this section&lt;/a&gt; in main.c.&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/384213?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 19:38:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c186270-72c0-4579-b949-93d8a86f1f5d</guid><dc:creator>SergeySK</dc:creator><description>&lt;p&gt;Hey Sigurd!&lt;br /&gt;In general, no problem - I myself like to work at night :)&lt;br /&gt;Unfortunately, there is example given by you, the conclusion is made using blocking calls&lt;/p&gt;
&lt;table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-hpc="" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="C" data-tagsearch-path="samples/drivers/uart/echo_bot/src/main.c"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td id="LC59" class="blob-code blob-code-inner js-file-line"&gt;&lt;span class="pl-c"&gt;/*&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L60" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="60"&gt;&lt;/td&gt;
&lt;td id="LC60" class="blob-code blob-code-inner js-file-line"&gt;&lt;span class="pl-c"&gt; * Print a null-terminated string character by character to the UART interface&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L61" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="61"&gt;&lt;/td&gt;
&lt;td id="LC61" class="blob-code blob-code-inner js-file-line"&gt;&lt;span class="pl-c"&gt; */&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L62" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="62"&gt;&lt;/td&gt;
&lt;td id="LC62" class="blob-code blob-code-inner js-file-line"&gt;&lt;span class="pl-k"&gt;void&lt;/span&gt; &lt;span class="pl-en"&gt;print_uart&lt;/span&gt;(&lt;span class="pl-k"&gt;char&lt;/span&gt; *buf)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L63" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="63"&gt;&lt;/td&gt;
&lt;td id="LC63" class="blob-code blob-code-inner js-file-line"&gt;{&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L64" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="64"&gt;&lt;/td&gt;
&lt;td id="LC64" class="blob-code blob-code-inner js-file-line"&gt;&lt;span class="pl-k"&gt;int&lt;/span&gt; msg_len = &lt;span class="pl-c1"&gt;strlen&lt;/span&gt;(buf);&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L65" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="65"&gt;&lt;/td&gt;
&lt;td id="LC65" class="blob-code blob-code-inner js-file-line"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L66" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="66"&gt;&lt;/td&gt;
&lt;td id="LC66" class="blob-code blob-code-inner js-file-line"&gt;&lt;span class="pl-k"&gt;for&lt;/span&gt; (&lt;span class="pl-k"&gt;int&lt;/span&gt; i = &lt;span class="pl-c1"&gt;0&lt;/span&gt;; i &amp;lt; msg_len; i++) {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L67" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="67"&gt;&lt;/td&gt;
&lt;td id="LC67" class="blob-code blob-code-inner js-file-line"&gt;&lt;span class="pl-c1"&gt;uart_poll_out&lt;/span&gt;(uart_dev, buf[i]);&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L68" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="68"&gt;&lt;/td&gt;
&lt;td id="LC68" class="blob-code blob-code-inner js-file-line"&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="L69" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="69"&gt;&lt;/td&gt;
&lt;td id="LC69" class="blob-code blob-code-inner js-file-line"&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br /&gt;I need the same thing, but with the interrupt.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/384186?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 14:52:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c6a40ea-4e53-46de-8702-61d0e72d4f14</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi Sergii,&lt;/p&gt;
&lt;p&gt;Sorry for the late answer!&lt;/p&gt;
&lt;p&gt;But I hopefully have information that can help you: the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/main/samples/drivers/uart/echo_bot"&gt;Zephyr UART echo sample&lt;/a&gt; uses interrupt driven UART for receiving messages, so you could learn how to do this from that sample.&lt;/p&gt;
&lt;p&gt;Is this what you were looking for?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/383514?ContentTypeID=1</link><pubDate>Fri, 26 Aug 2022 14:35:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16252544-63a0-4238-9539-3a823f381d06</guid><dc:creator>SergeySK</dc:creator><description>&lt;pre id="tw-target-text" class="tw-data-text tw-text-large tw-ta" dir="ltr"&gt;&lt;span class="Y2IQFc" lang="en"&gt;Hello Sigurd!

I have already searched through mountains in search of information. Start here
&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/uart.html#group__uart__interface_1gafc1aecb863e2456d73b78a49fcbad72e"&gt;UART &amp;mdash; Zephyr Project Documentation (nordicsemi.com)&lt;/a&gt;

I used the &amp;quot;peripheral_uart&amp;quot; example from SDK 2.0.0 to start with, but it uses an asynchronous uart.
I couldn&amp;#39;t find an example with an interrupt driven API.&lt;/span&gt;&lt;/pre&gt;
&lt;pre id="tw-target-text" class="tw-data-text tw-text-large tw-ta" dir="ltr"&gt;&lt;span class="Y2IQFc" lang="en"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/uart.html#group__uart__interface_1gafc1aecb863e2456d73b78a49fcbad72e"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 UART Interrupt mode send example</title><link>https://devzone.nordicsemi.com/thread/383473?ContentTypeID=1</link><pubDate>Fri, 26 Aug 2022 12:35:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2672b04-bff3-416f-855d-7843a62104c7</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;So that we are on the same page: Can you send me the link to the documentation you refer to?&lt;/p&gt;
[quote user=""]The SDK describes three options:[/quote]
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>