<?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>Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21450/unable-to-read-or-write-mma8652-registers-using-twi</link><description>[https://drive.google.com/open?id=0ByjgT_Zt3YyJS2tKQko3cW10SlU] 
 hi i am working on MMA8652 i am working on mma7660 twi example in sdk11 for nrf52.
i have changed the registers as the same way the MMA8652 need.
here is my read and write functions</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Apr 2017 13:40:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21450/unable-to-read-or-write-mma8652-registers-using-twi" /><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84148?ContentTypeID=1</link><pubDate>Thu, 27 Apr 2017 13:40:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3ce9532-338d-430e-a71e-151530ed98ef</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Yes, the twi_master driver is deprecated in favor of the new nrf_drv_twi.c driver. Unfortunately, I do not have a MMA8652 that I can test against. I modified the twi_sensor example in SDK v11.0.0 so that its more inline with the snippets I&amp;#39;ve put in the comments. It first does a nrf_drv_twi_tx to tell the MMA7660 which register it should read from, in this case  MMA7660_REG_XOUT. Then it reads 3 bytes which is MMA7660_REG_XOUT, MMA7660_REG_YOUT and MMA7660_REG_ZOUT and prints it to the uart. Here is the main file: &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/5633.main.c"&gt;main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84147?ContentTypeID=1</link><pubDate>Wed, 26 Apr 2017 14:40:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15d923fe-76ef-4896-a515-c5e7dc89023b</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;but in SDK it is showing that twi_master is deprecated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84146?ContentTypeID=1</link><pubDate>Wed, 26 Apr 2017 14:39:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b643ca5c-e739-4656-84a5-c5dbd24623c6</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;yes but it is not working. so that i am using twi_master example it is working fine and i able to read and write to the registers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84145?ContentTypeID=1</link><pubDate>Wed, 26 Apr 2017 12:37:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88b54585-ab4d-4cb8-b25e-880150becb00</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;@saiteja: Did you try my suggestions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84144?ContentTypeID=1</link><pubDate>Sat, 22 Apr 2017 13:16:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ee793ef-7bd9-405a-bc7a-4246d3537863</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;&lt;a href="https://drive.google.com/open?id=0ByjgT_Zt3YyJS2tKQko3cW10SlU"&gt;drive.google.com/open&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84139?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 12:23:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2ecd8ba-36f7-46d4-a260-634e504a9818</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Ok, try reading other registers and see if you get any thing other than zeroes. If you still get zeroes and you are sure that the addresses are correct, then the only thing I can suggest is that you need to check if the connections are correct.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84138?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 12:20:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fa245d2-f93f-432e-9e57-5dc39b2a374b</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;i do not have logic analyzer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84150?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 12:16:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77a6a753-37b6-477a-b045-92ad7fed11cd</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Atleast the TWI operations are returning NRF_SUCCESS. Can you verify that you&amp;#39;re writing to the correct register? Do you have a logic analyzer or similar so that you can perform a logic trace?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84137?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 12:08:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e685e34-2baa-4091-b6d7-e7f276ff0367</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;hi i have tried with that, it is showing NRF_SUCCESS on both TX andRX operation. but i am getting empty value on reg_read buffer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84142?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 09:31:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1620180-138f-4cc0-a64d-a73f8a3e32a2</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Could you try to just set the m_xfer_done flag in the twi handler and nothing else, i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;case NRF_DRV_TWI_EVT_DONE:
    //string_send(&amp;quot;1twirxsuc\r\n&amp;quot;);
    if ((p_event-&amp;gt;type == NRF_DRV_TWI_EVT_DONE) &amp;amp;&amp;amp;
            (p_event-&amp;gt;xfer_desc.type == NRF_DRV_TWI_XFER_TX))
    {
        if(m_set_mode_done != true)
        {
            m_set_mode_done  = true;
            return;
        }
        m_xfer_done = true;
    }
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84135?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 07:56:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7144b018-c260-4c9e-8cbb-8c05d1b4e045</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;updated my Question? with twi_event_handler function, please find it.
EDIT:--&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84141?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 07:13:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:150e0501-214e-4419-af50-e96597834f73</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;I afraid that we do not have any example for communicating with the MMA8652FC. Can you post the twi_event_handler function?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84140?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 05:33:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:450d59e8-0de2-4da6-a2d9-d3fbec166022</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;i have one doubt if i want to read data from register i need to TX register address and Then i need to read. here my  MMA8652_I2C_ADDR is  0X1D but in the mma8652 documentation, it is saying that use 0X3A for tx and 0X3B for rx operation. but i am unable to get register data even if done both methods. and also i am getting NRF_SUCCESS return code.
i s there any simple application to just read and write from MMA8652FC. thank you.
and also did i need to put the MMA8652 in standby and Active for both tx and rx operations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84136?ContentTypeID=1</link><pubDate>Thu, 20 Apr 2017 16:54:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0bb6bff-4564-4f8a-944c-bddf7ecc2113</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;i am getting NRF_SUCCESS after nrf_drv_twi_tx but  now i am getting NRF_BUSY for nrf_drv_twi_rx.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84143?ContentTypeID=1</link><pubDate>Thu, 20 Apr 2017 08:37:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f58544b-f61c-4c02-8aa0-565f6c28b56f</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;If you take a look at the documentation of &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/group__nrf__drv__twi.html#ga2c5ea8408254dfa9cbff55dbee171a95"&gt;nrf_drv_twi_tx&lt;/a&gt; you&amp;#39;ll see that nrf_drv_twi_tx returns NRF_ERROR_BUSY if there is a transfer on going. Like the TWI sensor example you have to wait for the previous transfer to finish by waiting for the m_xfer_done to be set in the twi event handler, i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;while(m_xfer_done == false);
err_code=nrf_drv_twi_tx(&amp;amp;m_twi_mma_8652, MMA8652_I2C_ADDR, &amp;amp;W_reg, sizeof(W_reg), false);
APP_ERROR_CHECK(err_code);
m_xfer_done = false;

while(m_xfer_done == false);
err_code = nrf_drv_twi_rx(&amp;amp;m_twi_mma_8652, MMA8652_I2C_ADDR, &amp;amp;W_reg, sizeof(W_reg));
APP_ERROR_CHECK(err_code);
m_xfer_done = false;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84149?ContentTypeID=1</link><pubDate>Thu, 20 Apr 2017 05:31:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3926f60f-afe0-4955-bbf3-41d03b34420b</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;Hi, the error code is NRF_ERROR_BUSY&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84151?ContentTypeID=1</link><pubDate>Wed, 19 Apr 2017 14:43:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9466478e-50b5-401f-9bf1-7cbc0840e18c</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Does nrf_drv_twi_tx return an error code? I do not understand what you mean by &lt;em&gt;&amp;quot;is salve address for all MMA8652FC is 0X1D?&amp;quot;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84154?ContentTypeID=1</link><pubDate>Wed, 19 Apr 2017 12:50:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0997e204-c884-4af2-b5da-bc39f8878508</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;is salve address for all MMA8652FC is 0X1D?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84153?ContentTypeID=1</link><pubDate>Wed, 19 Apr 2017 12:49:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:066df008-4b3e-4c70-a641-e9fa0e0af33c</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;the code stuck at nrf_drv_twi_tx&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Read or write MMA8652 registers using TWI</title><link>https://devzone.nordicsemi.com/thread/84152?ContentTypeID=1</link><pubDate>Wed, 19 Apr 2017 12:46:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5f91263-5d09-4f7a-928e-5bd9bee829cc</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;In the first code snippet, where does the program get &amp;quot;stuck&amp;quot;? Does &lt;code&gt;nrf_drv_twi_tx&lt;/code&gt; or &lt;code&gt;nrf_drv_twi_rx&lt;/code&gt; return an error code? If you do not tell the MMA8652 from which register address you&amp;#39;re going to read from by performing a nrf_drv_twi_tx() before nrf_drv_twi_rx, then it will just start reading from register 0x00. If you take a look in the MMA8652 Datasheet, found &lt;a href="http://www.nxp.com/assets/documents/data/en/data-sheets/MMA8652FC.pdf"&gt;here&lt;/a&gt;, you&amp;#39;ll see that the OUT_X_MSB data starts from 0x01 and not 0x00 like the MMA7660. Register 0x00 is default set to 0x00 in the MMA8652, so thats probably why the x value stays zero. Thus, the first method is the better choice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>