<?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 inconsistent read of slave device address location in nRF5 SDK 15.2</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42254/twi-inconsistent-read-of-slave-device-address-location-in-nrf5-sdk-15-2</link><description>Hi, 
 I am using nRF5 SDK 15.2 and the twi_sensor example to read over I2C a slave device &amp;#39;WhoAmI&amp;#39; memory location. I first tx the slave address (0x68) and then attempt to read the memory location at 0x00. The expected value to be read back out is 0xEA</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Aug 2019 11:17:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42254/twi-inconsistent-read-of-slave-device-address-location-in-nrf5-sdk-15-2" /><item><title>RE: TWI inconsistent read of slave device address location in nRF5 SDK 15.2</title><link>https://devzone.nordicsemi.com/thread/206589?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2019 11:17:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90482a55-d957-499b-83c3-de65266cad61</guid><dc:creator>BendaEng</dc:creator><description>&lt;p&gt;Hi Nikhilesh,&lt;/p&gt;
&lt;p&gt;Apologies on the late reply, I didn&amp;#39;t see this response. I used the following TWI (I2C) driver base code set when I began figuring out how to use the ICM 20948 with the nRF52832.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/jrowberg/i2cdevlib/blob/master/nRF51/I2CDev/I2Cdev.cpp"&gt;https://github.com/jrowberg/i2cdevlib/blob/master/nRF51/I2CDev/I2Cdev.cpp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;On a separate note, I found the ICM very difficult to integrate with and only ended up using the absolute orientation output (never tap detection).&lt;/p&gt;
&lt;p&gt;I also got a similar error when writing the DMP firmware. See the following for some potential fixes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.invensense.com/developers/forums/topic/icm-20948-driver-firmware-upload-fails/"&gt;https://www.invensense.com/developers/forums/topic/icm-20948-driver-firmware-upload-fails/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.invensense.com/developers/forums/topic/icm-20948-dmp/"&gt;https://www.invensense.com/developers/forums/topic/icm-20948-dmp/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI inconsistent read of slave device address location in nRF5 SDK 15.2</title><link>https://devzone.nordicsemi.com/thread/205436?ContentTypeID=1</link><pubDate>Thu, 22 Aug 2019 06:29:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39e72b7c-449f-446c-b596-85a40e6be07c</guid><dc:creator>asmita_patil</dc:creator><description>&lt;p&gt;have you solved your problem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI inconsistent read of slave device address location in nRF5 SDK 15.2</title><link>https://devzone.nordicsemi.com/thread/183364?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 09:02:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fee53ae5-5c21-433c-a765-beffe6b004c2</guid><dc:creator>nikhilesh</dc:creator><description>&lt;p&gt;Hey BendaEng,&lt;/p&gt;
&lt;p&gt;I am using nrf52840 with SDK 15.3. I see a lot of twi drivers and its confusing which one to use. I want to read the ICM 20948 sensor data in burst mode for my application. In the second step I want to use the tap detection in DMP, so i have to write the DMP firmware into the ICM. But my twi drivers seem to constantly return with err_code 0x11 or 0x03 errors. Please let me know which is the best twi drivers for ICM. Thanks and regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI inconsistent read of slave device address location in nRF5 SDK 15.2</title><link>https://devzone.nordicsemi.com/thread/165032?ContentTypeID=1</link><pubDate>Thu, 10 Jan 2019 22:11:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eced4d57-a3a9-47d1-b440-61e6ecf6b80b</guid><dc:creator>BendaEng</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the reply. Unfortunately that didn&amp;#39;t end up working, but I did figure the issue out. I&amp;#39;m not sure if this is consistent across all I2C slave devices, but in order to read back the address over and over the pointer address needed to be set prior to reading again. The device&amp;nbsp;(ICM-20948) may not keep that register information after a read request due to volatile memory or something.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This was the modifications that I made which worked.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void ICM20948_set_mode(void)
{
    ret_code_t err_code;

    /* Writing to pointer byte. */
    uint8_t reg_addr = 0x00; //WHO_AM_I address same as define on top.
    m_xfer_done = false;
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, ICM20948_ADDR, &amp;amp;reg_addr, 1, false);
    APP_ERROR_CHECK(err_code);
    while (m_xfer_done == false);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void read_sensor_data()
{
    ret_code_t err_code;
    m_xfer_done = false;
    uint8_t reg_addr = WHO_AM_I; //WHO_AM_I address same as define on top.
    //uint8_t reg_addr = ACCEL_XOUT_L; //Gyro x axis lowest 8 bits of data

    /* Writing to pointer byte. */
      err_code = nrf_drv_twi_tx(&amp;amp;m_twi, ICM20948_ADDR, &amp;amp;reg_addr, sizeof(reg_addr), false);
    APP_ERROR_CHECK(err_code);

    /* Read 1 byte from the specified address */
    while(m_xfer_done == false);
      err_code = nrf_drv_twi_rx(&amp;amp;m_twi, ICM20948_ADDR, &amp;amp;m_sample, sizeof(m_sample));
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI inconsistent read of slave device address location in nRF5 SDK 15.2</title><link>https://devzone.nordicsemi.com/thread/164865?ContentTypeID=1</link><pubDate>Thu, 10 Jan 2019 10:27:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26e06b5b-f6f8-4d4a-8069-eb40c83dca73</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Typically for I2C devices,&amp;nbsp;in order to read from a&amp;nbsp;specific&amp;nbsp;register, you would need to write the register address to the device first. However, I would recommend you to read the datasheet for the &lt;span&gt;I2C&lt;/span&gt; device you have, as the approach may vary. Down below I have attached the code to run if your device works in the typical manner.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;First you must write the register address (0x00) to the device.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t reg_addr = 0x00;

m_xfer_done = false;
err_code = nrf_drv_twi_tx(&amp;amp;m_twi, LM75B_ADDR, &amp;amp;reg_addr, 1, false);
APP_ERROR_CHECK(err_code);
while (m_xfer_done == false);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I can not see that you have done this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Next up, you&amp;nbsp;can read the register as followed:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint8_t m_sample;

.
.
.

m_xfer_done = false;
// Read 1 byte from the specified address
ret_code_t err_code = nrf_drv_twi_rx(&amp;amp;m_twi, LM75B_ADDR, &amp;amp;m_sample, sizeof(m_sample));
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>