<?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 Issue With Peripheral Sensors</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15445/twi-issue-with-peripheral-sensors</link><description>I&amp;#39;m building some code off of the twi_master_using_app_twi example which is available in the SDK (v11.0.0). 
 The two peripherals I&amp;#39;m working on are an accelerometer (LIS3DH) and gyroscope (L3GD20H). 
 I&amp;#39;m able to read and confirm the WHOAMI registers</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 01 Aug 2016 16:08:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15445/twi-issue-with-peripheral-sensors" /><item><title>RE: TWI Issue With Peripheral Sensors</title><link>https://devzone.nordicsemi.com/thread/58968?ContentTypeID=1</link><pubDate>Mon, 01 Aug 2016 16:08:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:767ed7ac-1e41-480c-9b2a-337258195860</guid><dc:creator>ag</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;Thanks for the reply!&lt;/p&gt;
&lt;p&gt;It&amp;#39;s my first time working with I2C/TWI but yea, that&amp;#39;s what I assumed too with the WHOAMI registers. From what I understand, both sensors have start up registers and are by default in &amp;quot;low power&amp;quot; mode so I think the first thing I have to do, like you said, is set the sensor to &amp;quot;normal&amp;quot; mode.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m trying to follow the init setup shown in lm75b.c. For the accelerometer (data sheet here &lt;a href="https://cdn-shop.adafruit.com/datasheets/LIS3DH.pdf"&gt;&lt;strong&gt;click&lt;/strong&gt;&lt;/a&gt;) I have:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    #define LIS3DH_INIT_TRANSFER_COUNT 1
    #define LIS3DH_CTRL_REG1 0x20
    #define LIS3DH_ADDR 0x18

    // Set default configuration of LIS3DH
    static uint8_t const default_config1[] = { LIS3DH_CTRL_REG1, 0x07 }; // Set CTRL_REG1 to 00000111 (0000 = 50 Hz, 0 = normal mode, 111 = Zen,Yen,Xen Enabled)
    
    app_twi_transfer_t_const lis3dh_init_transfers[LIS3DH_INIT_TRANSFER_COUNT] = 
    {
        APP_TWI_WRITE(LIS3DH_ADDR, default_config1, sizeof(default_config1, 0), 0);
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This gets called in main.c to initialize the sensor with app_twi_perform. Does that seem correct?&lt;/p&gt;
&lt;p&gt;Also, when I read the status register (0x27 on the accelerometer) I get back a value of 0xFF but the default value is 0x00... so it makes me want to believe that the sensor is doing &lt;em&gt;something&lt;/em&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Issue With Peripheral Sensors</title><link>https://devzone.nordicsemi.com/thread/58967?ContentTypeID=1</link><pubDate>Sun, 31 Jul 2016 16:10:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f2c16ab-ab8e-4192-9a1a-6c83f3a7786d</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;SInce you are able to read out the WHOAMI registers it seems safe to assume that you have configured the TWI and connected everything correctly. So  my bet would be that there are some &amp;quot;start up&amp;quot; registers in your sensors that need to be set. For example, some sensors I have worked with start up in sleep mode by default, and one have to manually start the sampling of sensor data. Maybe this was handled in the background in the Arduino drivers?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Issue With Peripheral Sensors</title><link>https://devzone.nordicsemi.com/thread/58966?ContentTypeID=1</link><pubDate>Sat, 30 Jul 2016 20:33:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b90737bc-40a0-46ce-b93f-06cb1be7c62e</guid><dc:creator>ag</dc:creator><description>&lt;p&gt;I also verified that the accelerometer works on an Arduino by using the simple example as shown here: &lt;a href="https://learn.adafruit.com/adafruit-lis3dh-triple-axis-accelerometer-breakout/wiring-and-test"&gt;learn.adafruit.com/.../wiring-and-test&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I used a similar Adafruit example for the gyroscope and it seems to work correctly there, too.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Issue With Peripheral Sensors</title><link>https://devzone.nordicsemi.com/thread/58965?ContentTypeID=1</link><pubDate>Sat, 30 Jul 2016 18:40:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:032b28f7-cfbd-4efa-99ab-fb5e6da1d261</guid><dc:creator>ag</dc:creator><description>&lt;p&gt;I might have been printing the status bits out wrong to my terminal. If I print it as a hex to Putty using app_trace_log I get 0xFF which is 1111 1111.&lt;/p&gt;
&lt;p&gt;For the gyroscope it looks like that means I&amp;#39;m getting new data: &lt;a href="http://www.st.com/content/ccc/resource/technical/document/datasheet/43/37/e3/06/b0/bf/48/bd/DM00036465.pdf/files/DM00036465.pdf/jcr:content/translations/en.DM00036465.pdf"&gt;www.st.com/.../en.DM00036465.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But the values of XYZ rotation still aren&amp;#39;t changing...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>