<?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>Clarification on nrf_drv_twi_rx being blocking</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79543/clarification-on-nrf_drv_twi_rx-being-blocking</link><description>Hello 
 nrf_drv_twi_rx and nrf_drv_twi_tx are non blocking calls? 
 in the SDK example, I see a while loop is used in the read call for instance which basically is blocking the caller function unless the m_xfer_done flag is set from within an interrupt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Sep 2021 09:17:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79543/clarification-on-nrf_drv_twi_rx-being-blocking" /><item><title>RE: Clarification on nrf_drv_twi_rx being blocking</title><link>https://devzone.nordicsemi.com/thread/329561?ContentTypeID=1</link><pubDate>Wed, 15 Sep 2021 09:17:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fe316e0-0c1d-4a07-a407-b9d37c6dff97</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Do you still see the unknown interrupts if you comment out the TWI code so there are no TWI&amp;nbsp; interrupts? 1 ms could match a typical tick rate for FreeRTOS, for instance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification on nrf_drv_twi_rx being blocking</title><link>https://devzone.nordicsemi.com/thread/329530?ContentTypeID=1</link><pubDate>Wed, 15 Sep 2021 06:33:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfab967e-f76f-4156-bb9b-f6d2a55a7e79</guid><dc:creator>morpho</dc:creator><description>&lt;p&gt;twi interrupt is the only interrupt configured in my application and I was curious if you could see if&amp;nbsp;the interrupt info in the screenshot actually relates to twi interrupt handler (doesn&amp;#39;t make sense since the interrupt doesn&amp;#39;t fire that fast in an application itself) but do you see why could be causing this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification on nrf_drv_twi_rx being blocking</title><link>https://devzone.nordicsemi.com/thread/329312?ContentTypeID=1</link><pubDate>Tue, 14 Sep 2021 06:40:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce20dfd4-74ec-4fca-a258-6335f8bc6c38</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I did not see a clear link between the image and the question about TWI to be honest. I do not see anything there, other than as you say you have a interrupt that looks like it happens every 1 ms and that runs for 11.5 us. I cannot say from this what i tis though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification on nrf_drv_twi_rx being blocking</title><link>https://devzone.nordicsemi.com/thread/329306?ContentTypeID=1</link><pubDate>Tue, 14 Sep 2021 06:22:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df26abc7-a81a-4882-90c8-60ad80bae38d</guid><dc:creator>morpho</dc:creator><description>&lt;p&gt;RIght on. Using task notifications sounds like a better approach which seems to be a lightweight version of semaphores in FreeRTOS. After the read call, `ulTaskNotifyTake() to take a semaphore, which supposedly puts the thread into sleep until it&amp;#39;s woken up within an twi_handler() via vTaskNotifyGiveFromISR()&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Do you have any idea about the image I shared?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification on nrf_drv_twi_rx being blocking</title><link>https://devzone.nordicsemi.com/thread/329220?ContentTypeID=1</link><pubDate>Mon, 13 Sep 2021 12:22:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a164f938-2725-4cf2-aa6b-b4e825159f83</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]nrf_drv_twi_rx and nrf_drv_twi_tx are non blocking calls? [/quote]
&lt;p&gt;The driver supports both blocking and non-blocking (asynchronous) mode, depending on how you initialize it. If you provide an event handler, calls will be non-blocking. See &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/hardware_driver_twi.html"&gt;driver documentation&lt;/a&gt; for details.&lt;/p&gt;
[quote user=""]Is this how the driver call is typically used...to avoid invoking it before the current read is done?[/quote]
&lt;p&gt;You typically do not want to busy wait like this as it prevents other (same or lower priority) tasks from running, and it wastes CPU cycles and thus power. In a real application you instead typically want to be in idle while waiting for the interrupt you get when the operation has completed. In other words, both busy waiting (waiting loops) and blocking mode are primarily suitable for as simple as possible demo code and experimentation, but not something you normally want to use in production code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>