<?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 Confusion-Receiving NACK on example code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70959/twi-confusion-receiving-nack-on-example-code</link><description>I&amp;#39;m having a lot of confusion with using TWI on this chip. I have been running example code that I found in this tutorial nRF5 SDK - Tutorial for Beginners Pt 35 B - TWI - I2C with MPU6050 Accelerometer &amp;amp; Gyro Sensor - YouTube . It basically copies the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 Feb 2021 01:46:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70959/twi-confusion-receiving-nack-on-example-code" /><item><title>RE: TWI Confusion-Receiving NACK on example code</title><link>https://devzone.nordicsemi.com/thread/296131?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 01:46:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c468e21-1e6d-488d-9d9d-c96d5bddd52c</guid><dc:creator>RishS</dc:creator><description>&lt;p&gt;Thank you for looking into this! That is a good point that I didn&amp;#39;t think about. I never questioned my source but maybe the sensor I got was a knock off- will investigate this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your help Edvin. I will leave this as verified&amp;nbsp;for now and may make a new thread&amp;nbsp;if my attempts to solve this still don&amp;#39;t work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Confusion-Receiving NACK on example code</title><link>https://devzone.nordicsemi.com/thread/293267?ContentTypeID=1</link><pubDate>Mon, 08 Feb 2021 09:40:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2daba61-0357-4cf1-be04-591543ef40c0</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I found an MPU6050 laying around, and I tested the WHO_AM_I register, and it worked for me.&lt;/p&gt;
&lt;p&gt;Can you try the unmodified example from Martin&amp;#39;s repo and use SDK14.2.0:&lt;/p&gt;
&lt;p&gt;Use the project nrf5-ble-mpu-simple\pca10056&lt;/p&gt;
&lt;p&gt;I needed to change the memory settings, according to the log output. I don&amp;#39;t remember what it was, but I changed the RAM start address to&amp;nbsp;0x20002A18 and the size to&amp;nbsp;0x3D5E8. Then you need to replace the preprocessor definition &amp;quot;MPU9150&amp;quot; to &amp;quot;MPU60x0&amp;quot; (keep the &amp;#39;x&amp;#39;), and then add these lines to the top of app_mpu.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then I modified the&amp;nbsp;app_mpu_init() function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t app_mpu_init(void)
{
    uint32_t err_code;
	
		uint8_t buffer;
	
	// Initate TWI or SPI driver dependent on what is defined from the project
	err_code = nrf_drv_mpu_init();
    if(err_code != NRF_SUCCESS) return err_code;

    uint8_t reset_value = 7; // Resets gyro, accelerometer and temperature sensor signal paths.
    err_code = nrf_drv_mpu_write_single_register(MPU_REG_SIGNAL_PATH_RESET, reset_value);
    if(err_code != NRF_SUCCESS) return err_code;

    // Chose  PLL with X axis gyroscope reference as clock source
    err_code = nrf_drv_mpu_write_single_register(MPU_REG_PWR_MGMT_1, 1);
    if(err_code != NRF_SUCCESS) return err_code;
	
		err_code = nrf_drv_mpu_read_registers(MPU_REG_WHO_AM_I, &amp;amp;buffer, 1);
		NRF_LOG_INFO(&amp;quot;read err_code = %d&amp;quot;, err_code);
		NRF_LOG_INFO(&amp;quot;buffer: 0b%d%d%d%d%d%d&amp;quot;, (1 &amp;amp;&amp;amp; (buffer &amp;amp; 1&amp;lt;&amp;lt;1)),
                                               (1 &amp;amp;&amp;amp; (buffer &amp;amp; 1&amp;lt;&amp;lt;2)),
                                               (1 &amp;amp;&amp;amp; (buffer &amp;amp; 1&amp;lt;&amp;lt;3)),
                                               (1 &amp;amp;&amp;amp; (buffer &amp;amp; 1&amp;lt;&amp;lt;4)),
                                               (1 &amp;amp;&amp;amp; (buffer &amp;amp; 1&amp;lt;&amp;lt;5)),
                                               (1 &amp;amp;&amp;amp; (buffer &amp;amp; 1&amp;lt;&amp;lt;6)));
        NRF_LOG_INFO(&amp;quot;buffer hex value: %02x&amp;quot;, buffer);

    return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When I run this, the log prints the WHO_AM_I register value 0x68, which according to this document is the default value:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf"&gt;https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;(page 45)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;
&lt;p&gt;I am not sure why it doesn&amp;#39;t reply as it should. It could be a knock off copy of the sensor for all I know. You may try to contact the manufacturer and ask why it doesn&amp;#39;t reply to that register.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Confusion-Receiving NACK on example code</title><link>https://devzone.nordicsemi.com/thread/293173?ContentTypeID=1</link><pubDate>Fri, 05 Feb 2021 17:17:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98a95bdd-4e28-44ab-a9d9-804cbafacfa4</guid><dc:creator>RishS</dc:creator><description>&lt;p&gt;It doesn&amp;#39;t reply. It is the correct register-Martin had it in a header file and it matches the data sheet, so it&amp;#39;s confusing why this is happening.&amp;nbsp;It seems to only be an issue with this register (either that or I just haven&amp;#39;t called his &amp;quot;read_registers&amp;quot; function properly- which doesnt make sense because I copied his example where he read data in another function).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Confusion-Receiving NACK on example code</title><link>https://devzone.nordicsemi.com/thread/293138?ContentTypeID=1</link><pubDate>Fri, 05 Feb 2021 14:44:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de95c14c-61fd-4b98-8b62-4f5ba30eb4ec</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t have the sensor, so I can&amp;#39;t check, but are you saying that the example (from Martin) doesn&amp;#39;t check the WHO_AM_I register, or that the sensor doesn&amp;#39;t reply to the WHO_AM_I register?&lt;/p&gt;
&lt;p&gt;If it is the last case, are you sure it is the correct register? Does it match the datasheet on the sensor?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Confusion-Receiving NACK on example code</title><link>https://devzone.nordicsemi.com/thread/293000?ContentTypeID=1</link><pubDate>Thu, 04 Feb 2021 23:21:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ec8c066-8c5a-441c-91d9-a8fa0d181e0f</guid><dc:creator>RishS</dc:creator><description>&lt;p&gt;Hi Edvin! Thank you for your response. This was very helpful the example worked out of the box which was amazing. One problem I noticed however was that Martin&amp;#39;s code doesn&amp;#39;t&amp;nbsp;verify the productID at the beginning to ensure it is communicating with the right device. I&amp;#39;m starting to suspect this was why I was receiving a Nack with my code because once I added that functionality in it performed exactly as my&amp;nbsp;own code did. I was wondering if you had any thoughts on why this wouldn&amp;#39;t work, the function I added&amp;nbsp;can be seen here, the register is 0x75 which matches my datasheet:&lt;/p&gt;
&lt;p&gt;uint32_t app_mpu_read_who_am_i(uint8_t * product_id)&lt;br /&gt;{&lt;br /&gt; return nrf_drv_mpu_read_registers(MPU_REG_WHO_AM_I, product_id, 1);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Everything else in my code matches the github you linked me- I&amp;#39;m running the nrf5-mpu-simple example. The accelerometer itself works its just this&amp;nbsp;readProductID() function giving me trouble&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Confusion-Receiving NACK on example code</title><link>https://devzone.nordicsemi.com/thread/291563?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2021 15:02:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a99107d4-822e-4ae2-8eed-2bc1d72a6503</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have not tried to follow the youtube tutorial that you linked to, but I know that a former colleague of mine created an example project for this sensor. Perhaps you can try it:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/Martinsbl/nrf5-mpu-examples"&gt;https://github.com/Martinsbl/nrf5-mpu-examples&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Read the readme on that repository, and run it on SDK14.2.0 and check that it is working before you run it in SDK17.0.2.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>