<?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>Two ways to send two or more bytes with nrf_drv_twi_tx</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29249/two-ways-to-send-two-or-more-bytes-with-nrf_drv_twi_tx</link><description>Hi! I use ICM-20602 motion sensor that is similar to MPU6050. Its communication type is also I2C. 
 I made I2C wrapping module for ICM-20602. In the module, I added i2c_write_byte and i2c_write_bytes functions like following code. 
 ret_code_t i2c_write_byte</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Jan 2018 08:02:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29249/two-ways-to-send-two-or-more-bytes-with-nrf_drv_twi_tx" /><item><title>RE: Two ways to send two or more bytes with nrf_drv_twi_tx</title><link>https://devzone.nordicsemi.com/thread/116362?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2018 08:02:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2abdeac9-fa04-4e44-8fc7-fc0ac69b21fb</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Thanks. I figured that maybe you were using the driver in non-blocking mode with an event handler. Then it wouldn&amp;#39;t work to call two tx functions right after one another like you do in i2c_write_byte(). But obviously you use your code in blocking mode so that can&amp;#39;t be the problem. Please get back to us when you have tested with a logic analyzer then.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two ways to send two or more bytes with nrf_drv_twi_tx</title><link>https://devzone.nordicsemi.com/thread/116360?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2018 07:38:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f647d72-3f94-4b8d-bc17-88a2c216a9aa</guid><dc:creator>neosarchizo</dc:creator><description>&lt;p&gt;@martinbl Here it is! Please ignore macro function.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ret_code_t i2c_init(){

#if NEOSARCHIZO_DEBUG == 1
    NRF_LOG_INFO(&amp;quot;i2c_init : start&amp;quot;);
#endif

    ret_code_t err_code;
    const nrf_drv_twi_config_t config =
    {
       .scl                = I2C_SCL_M,
       .sda                = I2C_SDA_M,
       .frequency          = NRF_TWI_FREQ_400K,
       .interrupt_priority = APP_IRQ_PRIORITY_LOW,
       .clear_bus_init     = false
    };
    
#if NEOSARCHIZO_DEBUG == 1
    NRF_LOG_INFO(&amp;quot;i2c_init : nrf_drv_twi_init&amp;quot;);
#endif

    err_code = nrf_drv_twi_init(&amp;amp;m_twi_master, &amp;amp;config, NULL, NULL);
    APP_ERROR_CHECK(err_code);

#if NEOSARCHIZO_DEBUG == 1
    NRF_LOG_INFO(&amp;quot;i2c_init : nrf_drv_twi_enable&amp;quot;);
#endif

    nrf_drv_twi_enable(&amp;amp;m_twi_master);

#if NEOSARCHIZO_DEBUG == 1
    NRF_LOG_INFO(&amp;quot;i2c_init : end&amp;quot;);
#endif

    return err_code;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two ways to send two or more bytes with nrf_drv_twi_tx</title><link>https://devzone.nordicsemi.com/thread/116359?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2018 07:31:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:447aed04-387e-4f17-adf0-c4de21b0d526</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Can you also show us the code that you use for initializing the TWI driver?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two ways to send two or more bytes with nrf_drv_twi_tx</title><link>https://devzone.nordicsemi.com/thread/116361?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2018 01:13:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d5ee7e1-b8ce-482d-9579-82d6cb49dfdd</guid><dc:creator>neosarchizo</dc:creator><description>&lt;p&gt;@Rknguyen Now, I&amp;#39;m not able to debug two methods. But I will soon update about them!
I will not use a scope, I will use a logic analyzer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two ways to send two or more bytes with nrf_drv_twi_tx</title><link>https://devzone.nordicsemi.com/thread/116356?ContentTypeID=1</link><pubDate>Sun, 07 Jan 2018 16:37:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02d1b41e-6309-461f-9a20-bdd478a1fc19</guid><dc:creator>RkNg</dc:creator><description>&lt;p&gt;So,what you got when using these two methods? And what is on your scope ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two ways to send two or more bytes with nrf_drv_twi_tx</title><link>https://devzone.nordicsemi.com/thread/116358?ContentTypeID=1</link><pubDate>Sun, 07 Jan 2018 13:22:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a060e66-9f76-46f5-8440-aac736fb0c19</guid><dc:creator>neosarchizo</dc:creator><description>&lt;p&gt;@rknguyen No, no!! I made typos. I modified this post. (data -&amp;gt; &amp;amp;data).
I know how to check I2C data as you said.
But the reason why I think so is that because &lt;code&gt;nrf_drv_twi_tx&lt;/code&gt; function has &lt;code&gt;no_stop&lt;/code&gt; parameter. The API docments said like following.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;no_stop : If set, the stop condition is not generated on the bus after the transfer has completed successfully (allowing for a repeated start in the next transfer).
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So, if I set &lt;code&gt;no_stop&lt;/code&gt; to false, and recall &lt;code&gt;nrf_drv_twi_tx&lt;/code&gt; function then only one transmission will occur.&lt;/p&gt;
&lt;p&gt;I understood like this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two ways to send two or more bytes with nrf_drv_twi_tx</title><link>https://devzone.nordicsemi.com/thread/116357?ContentTypeID=1</link><pubDate>Sun, 07 Jan 2018 10:33:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53de3c2d-cbda-49aa-8804-692be76edd1e</guid><dc:creator>RkNg</dc:creator><description>&lt;p&gt;Hi,
First, i think uint8_t tx_data[2] (1st function)  is different from uint8_t data (2nd function), while the nrf_drv_twi_rx require &amp;quot;uint8_t *p_data&amp;quot;. It would result in an incompatilble argument error when compiling&lt;/p&gt;
&lt;p&gt;And, for I2C, I would suggest that you could use a scope to capture I2C data and see if there is any difference between these 2 functions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>