<?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>How to access to the slave address and to manage successive nrf_drv_twi_tx() ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16105/how-to-access-to-the-slave-address-and-to-manage-successive-nrf_drv_twi_tx</link><description>Hello everyone, 
 I have a program which set configurations by using write (nrf_drv_twi_tx) in the registers of a sensor.
I use the SDK 8 in the nRF51. 
 Here is the code: 
 // *************************************** Temperature cfg *************</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 23 Dec 2016 15:31:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16105/how-to-access-to-the-slave-address-and-to-manage-successive-nrf_drv_twi_tx" /><item><title>RE: How to access to the slave address and to manage successive nrf_drv_twi_tx() ?</title><link>https://devzone.nordicsemi.com/thread/61414?ContentTypeID=1</link><pubDate>Fri, 23 Dec 2016 15:31:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39f2520f-91eb-49e0-a2af-11151e56911b</guid><dc:creator>Mahaliana</dc:creator><description>&lt;ol&gt;
&lt;li&gt;About the addressing, the problem came from the pin connectors.&lt;/li&gt;
&lt;li&gt;About the write, I had to transmit the reg address and the data in one line.
Thanks a lot for your help.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to access to the slave address and to manage successive nrf_drv_twi_tx() ?</title><link>https://devzone.nordicsemi.com/thread/61413?ContentTypeID=1</link><pubDate>Tue, 20 Sep 2016 08:18:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85d43542-2a3f-4a29-bfa7-e4300ddaa7e3</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;@mahaliana : Could you try to set a flag in the twi_event_handler when you get the NRF_DRV_TWI_TX_DONE event, i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context) 
{ 
   switch(p_event-&amp;gt;type) { 
      case NRF_DRV_TWI_RX_DONE: 
      m_xfer_done = true;
      break; 
   default: 
      break; 
  } 
} 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and then initiate a twi transaction like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;m_xfer_done = false; 
ret_code = nrf_drv_twi_rx(&amp;amp;p_twi_instance, start_byte, &amp;amp;start_byte, 1, false); 
while(!m_xfer_done){//do nothing} 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This way you will wait until the TWI transaction is finished before starting the next one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to access to the slave address and to manage successive nrf_drv_twi_tx() ?</title><link>https://devzone.nordicsemi.com/thread/61412?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2016 13:32:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f675effb-1a5f-4935-aecf-df3a121cd213</guid><dc:creator>Mahaliana</dc:creator><description>&lt;p&gt;Thank you for your answer.
Yes, I am using that but it does not solve my problem.
Please look above, I edited the original post to give more details.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to access to the slave address and to manage successive nrf_drv_twi_tx() ?</title><link>https://devzone.nordicsemi.com/thread/61411?ContentTypeID=1</link><pubDate>Mon, 05 Sep 2016 08:17:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec377465-8d19-405b-ad57-d51c0a7e9f68</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Are you using the TWI driver(nrf_drv_twi) from SKD v9.0.0 in SDK v8.0.0? If that is the case, then the following code&lt;/p&gt;
&lt;p&gt;uint8_t address = 0x77;
ret_code = nrf_drv_twi_tx(&amp;amp;p_twi_instance, address, &amp;amp;press_reg, 1, true);&lt;/p&gt;
&lt;p&gt;should result in the &lt;code&gt;NRF_DRV_TWI_TX_DONE&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to access to the slave address and to manage successive nrf_drv_twi_tx() ?</title><link>https://devzone.nordicsemi.com/thread/61410?ContentTypeID=1</link><pubDate>Fri, 02 Sep 2016 14:28:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adfe76b6-17ae-4093-84d8-5ad17eeb5fb6</guid><dc:creator>Mahaliana</dc:creator><description>&lt;p&gt;At the beginning, I followed what was told in this link :
&lt;a href="http://devzone.nordicsemi.com/question/48894/hardware-twii2c-example/"&gt;link text&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So the code where I initialize the TWI driver is :&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;&lt;code&gt;ret_code_t ret_code;
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;pre&gt;&lt;code&gt;const nrf_drv_twi_t     p_twi_instance = NRF_DRV_TWI_INSTANCE(1); 
nrf_drv_twi_config_t    p_twi_config = NRF_DRV_TWI_DEFAULT_CONFIG(1);
ret_code = nrf_drv_twi_init(&amp;amp;p_twi_instance, &amp;amp;p_twi_config, twi_event_handler); 
APP_ERROR_CHECK(ret_code);  
nrf_drv_twi_enable(&amp;amp;p_twi_instance); 
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;I tried what you adviced me but the result is the same, i.e. error event is generated.
And what I wanted to explain was that I had to pass through the slave_address 0x76 (the front 0x77) by using the for loop, as shown in the first code. I can&amp;#39;t obtain directly a TX_SENT or a RX_READY by passing through the slave_address 0x77 the first time.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to access to the slave address and to manage successive nrf_drv_twi_tx() ?</title><link>https://devzone.nordicsemi.com/thread/61409?ContentTypeID=1</link><pubDate>Fri, 02 Sep 2016 11:39:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d841d4d-606d-4084-a2b3-bac619a144af</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Could you post the code where you initialize the TWI driver, i.e. nrf_drv_twi_init?1&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1)&lt;/strong&gt; You mean that you cannot call &lt;code&gt;nrf_drv_twi_tx&lt;/code&gt;the following way&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_twi_tx(&amp;amp;p_twi_instance, 0x77, &amp;amp;press_reg, 1, true);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;but you have to call it like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t address = 0x77;
nrf_drv_twi_tx(&amp;amp;p_twi_instance, address, &amp;amp;press_reg, 1, true);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You could try to type cast it, i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_twi_tx(&amp;amp;p_twi_instance, (uint8_t)0x77, &amp;amp;press_reg, 1, true);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;2)&lt;/strong&gt; If you have provided it with a event handler,i.e. that the driver is event-driven and not blocking, then halting and starting the nRF51 could interfere with the event generation and handling.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>