<?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>Bytes are lost when sending with nrfx_uarte_tx in uarte_handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/118424/bytes-are-lost-when-sending-with-nrfx_uarte_tx-in-uarte_handler</link><description>Hello, 
 I&amp;#180;m trying to send a paket of databytes. For some reasons I need to send it byte by byte (that&amp;#180;s not changeable). 
 I have inited the uarte with a handler: 
 
 nrfx_uarte_init (&amp;amp; m_uarte1_inst , &amp;amp; m_uarte1_config , uarte1_handler ); 
 
 The first</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 Jan 2025 09:20:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/118424/bytes-are-lost-when-sending-with-nrfx_uarte_tx-in-uarte_handler" /><item><title>RE: Bytes are lost when sending with nrfx_uarte_tx in uarte_handler</title><link>https://devzone.nordicsemi.com/thread/520520?ContentTypeID=1</link><pubDate>Wed, 29 Jan 2025 09:20:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e6ad11b-c232-4047-8a5b-dcc850f43b17</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="SvenSi"]Could you explain it more detailed why it is a problem to use the function in the interrupt context? Is there a function that can be used?[/quote]
&lt;p&gt;As you can see in &lt;a href="https://github.com/nrfconnect/sdk-hal_nordic/blob/8f013ea950f41bf69b18bf688bfb0dd80a3fdc44/nrfx/drivers/src/nrfx_uarte.c#L417-L418"&gt;nrfx_uarte_tx&lt;/a&gt;(), the function has some loops waiting for stuff. In other words, it is blocking. And blocking functions is generally not a good idea in an interrupt context. &lt;/p&gt;
[quote user="SvenSi"]Yes, it seems to be a timing problem. I tested to use a workqueue to send the next byte. This seems to be ok, but now there is a delay between the bytes (as expected), so I would like to get it back to the ISR.[/quote]
&lt;p&gt;The delay is likely because the workqueue is scheduled by the Zephyr scheduler. To make it faster, either do not use the scheduler but a polling function and global variable or semaphore to be really fast, or give the workqueue a higher priority.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bytes are lost when sending with nrfx_uarte_tx in uarte_handler</title><link>https://devzone.nordicsemi.com/thread/520446?ContentTypeID=1</link><pubDate>Tue, 28 Jan 2025 17:11:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96fdb29e-ae2c-4fa2-ac46-c89e299be02d</guid><dc:creator>SvenSi</dc:creator><description>&lt;p&gt;Yes, it seems to be a timing problem. I tested to use a workqueue to send the next byte. This seems to be ok, but now there is a delay between the bytes (as expected), so I would like to get it back to the ISR.&lt;/p&gt;
&lt;p&gt;Could you explain it more detailed why it is a problem to use the function in the interrupt context? Is there a function that can be used?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bytes are lost when sending with nrfx_uarte_tx in uarte_handler</title><link>https://devzone.nordicsemi.com/thread/520402?ContentTypeID=1</link><pubDate>Tue, 28 Jan 2025 15:07:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46f018b2-b0e3-45b9-a17b-db22bb43a26b</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Often errors like this comes from calling functions from interrupt contexts. This can interfere with peripheral timing.&lt;/p&gt;
&lt;p&gt;See how the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/1aa2f9d42791ff37061af43aa8fa97120f9fbeb7/samples/boards/nordic/nrfx_prs/src/main.c#L271"&gt;nrfx_prs sample&lt;/a&gt; uses a semaphore to check if the transfer is done, set in the DONE callback instead of calling nrfx_uarte_tx directly.&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></channel></rss>