<?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>initial TWI in nrf52832</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15237/initial-twi-in-nrf52832</link><description>I have hard time in start a twi in nrf52832 with SDK11.0, I can&amp;#39;t initial twi ,whatever i do ,when i build is still an error ,here is my code: 
 static const nrf_drv_twi_t iic0_acc0_instance = NRF_DRV_TWI_INSTANCE(0);
//const nrf_drv_twi_t m_twi_mma_7660</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Jul 2016 05:43:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15237/initial-twi-in-nrf52832" /><item><title>RE: initial TWI in nrf52832</title><link>https://devzone.nordicsemi.com/thread/58177?ContentTypeID=1</link><pubDate>Thu, 21 Jul 2016 05:43:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d46ea0cc-53de-45bd-9974-339f554c6643</guid><dc:creator>atune</dc:creator><description>&lt;p&gt;That really shouldn&amp;#39;t be possible though. If &lt;code&gt;#define TWI0_ENABLED 1&lt;/code&gt; exists and the file defining it is included, it should compile. Did you use an example project as a base for your app? If you did, did you change the nrf_drv_config.h in the example project&amp;#39;s &lt;code&gt;\config\&lt;/code&gt; folder (instead of the path I listed before)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: initial TWI in nrf52832</title><link>https://devzone.nordicsemi.com/thread/58178?ContentTypeID=1</link><pubDate>Thu, 21 Jul 2016 01:53:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d12d23e-f482-45a7-844a-bad4084b41d6</guid><dc:creator>Zou</dc:creator><description>&lt;p&gt;I have rebuiled it ,but it is always &amp;quot;wrong configration&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: initial TWI in nrf52832</title><link>https://devzone.nordicsemi.com/thread/58176?ContentTypeID=1</link><pubDate>Wed, 20 Jul 2016 07:29:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20d68d9e-60ff-4a13-b3d3-e6933372904a</guid><dc:creator>atune</dc:creator><description>&lt;p&gt;Did you clean / &lt;em&gt;re&lt;/em&gt;build it? Keil sometimes messes up when macros are changed and the old values are still used in compilation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: initial TWI in nrf52832</title><link>https://devzone.nordicsemi.com/thread/58180?ContentTypeID=1</link><pubDate>Wed, 20 Jul 2016 06:07:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:898073a7-42a6-443b-8329-ac5b3e1d114e</guid><dc:creator>Zou</dc:creator><description>&lt;p&gt;In this mode ,I have changed&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define TWI0_ENABLED 1 
#if (TWI0_ENABLED == 1)
#define TWI0_USE_EASY_DMA 0

#define TWI0_CONFIG_FREQUENCY    NRF_TWI_FREQ_100K
#define TWI0_CONFIG_SCL          0
#define TWI0_CONFIG_SDA          1
#define TWI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW

#define TWI0_INSTANCE_INDEX      0
#endif
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But when I build it ,there is this error too.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: initial TWI in nrf52832</title><link>https://devzone.nordicsemi.com/thread/58179?ContentTypeID=1</link><pubDate>Wed, 20 Jul 2016 05:49:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d16d41f1-cfcd-4d0a-bc98-f3e160bd9fde</guid><dc:creator>atune</dc:creator><description>&lt;p&gt;So the &lt;em&gt;compiler&lt;/em&gt; is telling you that nrf_drv_twi.c has an error with the message &lt;code&gt;Wrong configuration.&lt;/code&gt;.
In &lt;a href="https://devzone.nordicsemi.com/question/87813/how-to-config-twi-in-nrf52832/"&gt;your other question&lt;/a&gt; you got to this part:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#if (defined(TWIM_IN_USE) &amp;amp;&amp;amp; defined(TWI_IN_USE))
    // TWIM and TWI combined
    #define CODE_FOR_TWIM(code) if (p_instance-&amp;gt;use_easy_dma) { code }
    #define CODE_FOR_TWI(code)  else { code }
#elif (defined(TWIM_IN_USE) &amp;amp;&amp;amp; !defined(TWI_IN_USE))
    // TWIM only
    #define CODE_FOR_TWIM(code) { code }
    #define CODE_FOR_TWI(code)
#elif (!defined(TWIM_IN_USE) &amp;amp;&amp;amp; defined(TWI_IN_USE))
    // TWI only
    #define CODE_FOR_TWIM(code)
    #define CODE_FOR_TWI(code)  { code }
#else
    #error &amp;quot;Wrong configuration.&amp;quot;
#endif
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So TWIM_IN_USE and/or TWI_IN_USE need to be defined for you to be able to compile the file.
They are defined in nrf_drv_twi.h:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// This set of macros makes it possible to exclude parts of code when one type
// of supported peripherals is not used.
#if ((TWI0_ENABLED == 1 &amp;amp;&amp;amp; TWI0_USE_EASY_DMA == 1) || \
     (TWI1_ENABLED == 1 &amp;amp;&amp;amp; TWI1_USE_EASY_DMA == 1))
    #define TWIM_IN_USE
#endif
#if ((TWI0_ENABLED == 1 &amp;amp;&amp;amp; TWI0_USE_EASY_DMA != 1) || \
     (TWI1_ENABLED == 1 &amp;amp;&amp;amp; TWI1_USE_EASY_DMA != 1))
    #define TWI_IN_USE
#endif
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which leads us to you needing to #define a combination of those macros. The SDK collects driver definitions in \components\drivers_nrf\config\nrf_drv_config.h:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define TWI0_ENABLED 0

#if (TWI0_ENABLED == 1)
#define TWI0_USE_EASY_DMA 0

#define TWI0_CONFIG_FREQUENCY    NRF_TWI_FREQ_100K
#define TWI0_CONFIG_SCL          0
#define TWI0_CONFIG_SDA          1
#define TWI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW

#define TWI0_INSTANCE_INDEX      0
#endif

#define TWI1_ENABLED 0

#if (TWI1_ENABLED == 1)
#define TWI1_USE_EASY_DMA 0

#define TWI1_CONFIG_FREQUENCY    NRF_TWI_FREQ_100K
#define TWI1_CONFIG_SCL          0
#define TWI1_CONFIG_SDA          1
#define TWI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW

#define TWI1_INSTANCE_INDEX      (TWI0_ENABLED)
#endif

#define TWI_COUNT                (TWI0_ENABLED + TWI1_ENABLED)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The frequency, scl/sda pins and irq priority are used in a nrf_drv_twi.h macro:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**
 * @brief TWI master driver instance default configuration.
 */
#define NRF_DRV_TWI_DEFAULT_CONFIG(id)                            \
{                                                                 \
    .frequency          = CONCAT_3(TWI, id, _CONFIG_FREQUENCY),   \
    .scl                = CONCAT_3(TWI, id, _CONFIG_SCL),         \
    .sda                = CONCAT_3(TWI, id, _CONFIG_SDA),         \
    .interrupt_priority = CONCAT_3(TWI, id, _CONFIG_IRQ_PRIORITY) \
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So you don&amp;#39;t need to care about those if you don&amp;#39;t want to.&lt;/p&gt;
&lt;p&gt;Based on your code, all you need to do is change &lt;code&gt;#define TWI0_ENABLED 0&lt;/code&gt; to &lt;code&gt;1&lt;/code&gt; and you&amp;#39;re hopefully one step closer to making it work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>