<?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>TWI doesn&amp;#39;t work when a handler is set</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29791/twi-doesn-t-work-when-a-handler-is-set</link><description>I&amp;#39;m learning how to use TWI with the nRF52 PDK, and I have it connected to a LSM6DS3 module for testing. 
 When initializing the TWI, if I use the following line, it works great: 
 ret_code_t err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_config, NULL, NULL</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 31 Jan 2018 09:35:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29791/twi-doesn-t-work-when-a-handler-is-set" /><item><title>RE: TWI doesn't work when a handler is set</title><link>https://devzone.nordicsemi.com/thread/118189?ContentTypeID=1</link><pubDate>Wed, 31 Jan 2018 09:35:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f7a9b7f-8032-4f1a-874c-2283148b58ef</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;What is not called? The interrupt handler? I recommend that you post a new thread where you described your code and the issue in more details. This will make it easier to help you get your issue sorted out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI doesn't work when a handler is set</title><link>https://devzone.nordicsemi.com/thread/118188?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2018 19:54:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac842a57-af3d-4ab8-b186-1c4cd2aded73</guid><dc:creator>Steph van Schalkwyk</dc:creator><description>&lt;p&gt;I&amp;#39;m getting the same problem. I&amp;#39;ve removed all NRF_LOG_* from the interrupt handler, but it still isn&amp;#39;t called.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const nrf_drv_twi_config_t twi_SI7021_config = {
       .scl                = ARDUINO_SCL_PIN,
       .sda                = ARDUINO_SDA_PIN,
       .frequency          = NRF_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_LOW, // I&amp;#39;ve tried HIGH
       .clear_bus_init     = false
    };

err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_SI7021_config, twi_handler, NULL);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI doesn't work when a handler is set</title><link>https://devzone.nordicsemi.com/thread/118187?ContentTypeID=1</link><pubDate>Thu, 11 Jan 2018 10:21:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f03c3a8d-620c-43e7-ae09-eeffaee69da3</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;A little late to the party, but for future readers I just answered a similar question &lt;a href="https://devzone.nordicsemi.com/question/187271/nrf52832-executing-twi-function-from-app_timer-handler/"&gt;here&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;NRF_LOG_FLUSH() is a &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/nrf_log.html?cp=4_0_0_3_25_2_0#nrf_log_usage_control"&gt;blocking function&lt;/a&gt; and if you are using UART as backend this is using interrupts while printing messages. Hence, you are triggering interrupts from within an interrupt context and this might cause priority issues. If you are using RTT as backend it will not use interrupts the same way, but since NRF_LOG_FLUSH() is blocking and since it takes a significant amount of time to format a string you should never flush in an interrupt context. NRF_LOG_FLUSH() is intended to be used only in main context.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI doesn't work when a handler is set</title><link>https://devzone.nordicsemi.com/thread/118186?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2017 19:04:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:308352ec-d2d0-414d-bbf0-665748bca058</guid><dc:creator>zolotiyeruki</dc:creator><description>&lt;p&gt;It appears that having NRF_LOG_FLUSH() in the event handler is what causes the problem.  I don&amp;#39;t know the precise root cause, but I suspect that it has something to do with calling it from within what is effectively an ISR.  Removing that statement allowed the code to run as expected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI doesn't work when a handler is set</title><link>https://devzone.nordicsemi.com/thread/118183?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2017 19:03:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc577ad7-7bbf-43ba-9ff6-3b4ed5f6edae</guid><dc:creator>zolotiyeruki</dc:creator><description>&lt;p&gt;It appears that having NRF_LOG_FLUSH() in the event handler is what causes the problem.  I don&amp;#39;t know the precise root cause, but I suspect that it has something to do with calling it from within what is effectively an ISR.  Removing that statement allowed the code to run as expected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI doesn't work when a handler is set</title><link>https://devzone.nordicsemi.com/thread/118184?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2017 16:00:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4bd8f57-2282-407b-b173-cf6b362b1991</guid><dc:creator>zolotiyeruki</dc:creator><description>&lt;p&gt;Here&amp;#39;s the nrf_drv_twi_config_t:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    const nrf_drv_twi_config_t twi_lm75b_config = {
   .scl                = ARDUINO_SCL_PIN,
   .sda                = ARDUINO_SDA_PIN,
   .frequency          = NRF_TWI_FREQ_100K,
   .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
   .clear_bus_init     = false
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I actually used the twi_scanner code as the basis for my main.c, although there&amp;#39;s little resemblance left after all my edits :)  I&amp;#39;ll try modifying the twi_sensor example and see if I have any more luck.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI doesn't work when a handler is set</title><link>https://devzone.nordicsemi.com/thread/118185?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2017 06:52:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f3f4eb2-3fd6-4756-98e2-f2a18d4ad3f5</guid><dc:creator>Knut Auvor Grythe</dc:creator><description>&lt;p&gt;I don&amp;#39;t see anything particularly wrong with the way you&amp;#39;re initializing twi, although you&amp;#39;re not sharing the contents of your nrf_drv_twi_config_t. Your main() doesn&amp;#39;t have logic for waiting for the interrupt, but I assume you know that. Have you considered starting with the examples/peripheral/twi_sensor example in the SDK? It&amp;#39;s a relatively simple interrupt-based TWI example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>