<?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>Issue Using Interrupt Driven UART Callback in nRFConnect To Transmit Data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92161/issue-using-interrupt-driven-uart-callback-in-nrfconnect-to-transmit-data</link><description>I am having trouble getting the data (7 ASCII characters) transmitted via UART using the interrupt driven mode. The uart_fifo_fill function returns a positive number (the exact number of characters I requested to send) but it actually doesn&amp;#39;t transmit</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Sep 2022 13:09:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92161/issue-using-interrupt-driven-uart-callback-in-nrfconnect-to-transmit-data" /><item><title>RE: Issue Using Interrupt Driven UART Callback in nRFConnect To Transmit Data</title><link>https://devzone.nordicsemi.com/thread/387934?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2022 13:09:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59e9bc07-0b3a-448d-905c-461863ec0b01</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Are you able to share a minimal version of your project that will allow me to replicate the issue here? I can make the ticket private if helps.&lt;/p&gt;
[quote user="DataMate"]The tx uart&amp;nbsp;should not be disabled here because the data has apparently not yet been sent.&amp;nbsp; [/quote]
&lt;p&gt;&lt;span&gt;I don&amp;#39;t understand why it fails when you disable the TX IRQ inside the UART ISR. While the data may not have been transmitted at that point, it has been loaded to the UARTE&amp;#39;s DMA buffer. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have not been able to reproduce the issue on my side either (using SDK v2.1.0). I also tried to look for relevant issues in the Zephyr release notes, but could not seem to find anything. &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Not sure if it&amp;#39;s worth mentioning or not, but uart_fifo_fill() will transmit up to &amp;#39;CONFIG_UART_1_NRF_TX_BUFFER_SIZE&amp;#39; bytes in one go (&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/97c4a1a6d1bda83f0272d9bbf68b211efadc7b4a/drivers/serial/uart_nrfx_uarte.c#L1598"&gt;implementation&lt;/a&gt;). This means the UART callback is only invoked once when the data to transmit is less than CONFIG_UART_1_NRF_TX_BUFFER_SIZE in length.&lt;/p&gt;
[quote user="DataMate"]There I tried polling with &lt;strong&gt;uart_irq_tx_complete&lt;/strong&gt;, but that took over 900 ms for 7 characters at 115200 baud, 1 stop bit, even parity!&amp;nbsp;[/quote]
&lt;p&gt;This function can only be used inside the UART ISR as noted here: &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/uart.html#c.uart_irq_tx_complete"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/uart.html#c.uart_irq_tx_complete&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue Using Interrupt Driven UART Callback in nRFConnect To Transmit Data</title><link>https://devzone.nordicsemi.com/thread/387762?ContentTypeID=1</link><pubDate>Sun, 25 Sep 2022 09:45:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10a53dce-e7a0-4f42-95f2-b008eb54b4c2</guid><dc:creator>DataMate</dc:creator><description>&lt;p&gt;UART pin assignments are correct for the Fanstel board I&amp;#39;m using.&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I found the problem.&amp;nbsp; It&amp;#39;s in the callback:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:#0000ff;font-family:&amp;#39;courier new&amp;#39;, courier;font-size:75%;"&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;if (tx_data_idx == tx_data_length)&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#0000ff;font-family:&amp;#39;courier new&amp;#39;, courier;font-size:75%;"&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#0000ff;font-family:&amp;#39;courier new&amp;#39;, courier;font-size:75%;"&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#ff0000;"&gt;uart_irq_tx_disable(dev);&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#0000ff;font-family:&amp;#39;courier new&amp;#39;, courier;font-size:75%;"&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tx_data_idx = 0;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#0000ff;font-family:&amp;#39;courier new&amp;#39;, courier;font-size:75%;"&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; k_sem_give(&amp;amp;tx_sem);&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#0000ff;font-family:&amp;#39;courier new&amp;#39;, courier;font-size:75%;"&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The tx uart&amp;nbsp;should not be disabled here because the data has apparently not yet been sent.&amp;nbsp; Evidently, the positive return value of &lt;strong&gt;uart_fifo_fill&lt;/strong&gt; only&amp;nbsp;indicates the number of characters that have been successfully written to the tx fifo, not the number successfully transmitted.&amp;nbsp; Consequently, I need to first wait until the transfer is complete before disabling the tx uart, but this should not be done in the interrupt service routine callback which could block subsequent interrupts, so I removed &lt;strong&gt;uart_irq_tx_disable&lt;/strong&gt; from that conditional block and placed it after &lt;strong&gt;k_sem_take&lt;/strong&gt; in &lt;strong&gt;uart_irq_tx&lt;/strong&gt;.&amp;nbsp; There I tried polling with &lt;strong&gt;uart_irq_tx_complete&lt;/strong&gt;, but that took over 900 ms for 7 characters at 115200 baud, 1 stop bit, even parity!&amp;nbsp; That prevented me from&amp;nbsp;getting a response from the receiver via the uart (not shown here in the code) in time.&amp;nbsp; Do you know why that function takes so long?&amp;nbsp; If I simply use a &lt;strong&gt;k_usleep&lt;/strong&gt; of 500 us, I receive&amp;nbsp;the response, but I&amp;#39;d rather use&amp;nbsp;&amp;nbsp;&lt;strong&gt;uart_irq_tx_complete&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;which seems to be intended for that purpose.&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue Using Interrupt Driven UART Callback in nRFConnect To Transmit Data</title><link>https://devzone.nordicsemi.com/thread/387528?ContentTypeID=1</link><pubDate>Thu, 22 Sep 2022 13:53:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:818316a7-7a29-4faf-8896-0d2ea9846395</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Could you please try to double check the UART pin assignments to make sure they match your board? I tried to use your code with SDK 2.1.0, but did not manage to reproduce the problem.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/1778.pastedimage1663854612198v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Test project:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/7635.interrupt_5F00_uart_5F00_sdk2.1.0.zip"&gt;devzone.nordicsemi.com/.../7635.interrupt_5F00_uart_5F00_sdk2.1.0.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Log output:&lt;/p&gt;
&lt;p&gt;*** Booting Zephyr OS build v3.1.99-ncs1&amp;nbsp; ***&lt;br /&gt;Test message&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART data transmitted&lt;br /&gt;TX length 14&lt;br /&gt;Hello World! nrf52840dk_nrf52840&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>