<?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 can I avoid sending a repeated start between TWI write and TWI read?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20032/how-can-i-avoid-sending-a-repeated-start-between-twi-write-and-twi-read</link><description>I am communicating with a temperature sensor (MLX90614), which has flag register. However, in order to read this register, I must send a read sequence without issuing the repeated start between the write and read operations. Here is what I want to do</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Nov 2017 07:41:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20032/how-can-i-avoid-sending-a-repeated-start-between-twi-write-and-twi-read" /><item><title>RE: How can I avoid sending a repeated start between TWI write and TWI read?</title><link>https://devzone.nordicsemi.com/thread/77978?ContentTypeID=1</link><pubDate>Wed, 15 Nov 2017 07:41:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45019284-758d-4250-bc22-2c81cfb20860</guid><dc:creator>SteinarK</dc:creator><description>&lt;p&gt;I had the same challenges in reading the flag register in the mlx90614. The datasheet of the mlx90614 says that only read/write word of the SMBUS standard 2.0 protocol is supported, while for the flag register read it does only state &amp;quot;Behaves like read command... The difference between
read and read flags is that the latter does not have a repeated start bit&amp;quot;. Based on that info your sequence seems to be interpreted correctly.&lt;/p&gt;
&lt;p&gt;However, in a preliminary application note (see e.g. &lt;a href="https://www.pololu.com/file/0J171/MLX90614_SMBus.pdf)"&gt;www.pololu.com/.../MLX90614_SMBus.pdf)&lt;/a&gt; there is a figure for the communication flow and the following pseudo code for the read of the flag register:&lt;/p&gt;
&lt;p&gt;Pseudo code example: Flags reading&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Send START bit&lt;/li&gt;
&lt;li&gt;Send SLA+W&lt;/li&gt;
&lt;li&gt;Send Command 0xF0&lt;/li&gt;
&lt;li&gt;Read Data Byte Low (master must send ACK bit)&lt;/li&gt;
&lt;li&gt;Read Data Byte High (master must send ACK bit)&lt;/li&gt;
&lt;li&gt;Read PEC (master can send ACK or NACK)&lt;/li&gt;
&lt;li&gt;Send STOP bit&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I.e. it is not only the repeated start bit that is omitted, but also the SLA+R. After the mlx90614 has acknowledged the 0xF0 command it immediately start  to transmit its flag register data.
It seems to me that the Master have to change state from MasterTransmit (MT) to MasterRead (MR) in between step 3 and 4. I&amp;#39;m using the twi hw in my microcontroller (which works flawlessly for the read/write word), but changing from MT to MR (repeated start followed by  SLA+R) without following the std SMBUS protocol seems to be impossible. I solved it by implementing some code based on the code found in the above referred application note to take control of the SDA/SCL in sw in the case of reading the flag register (not use the twi hw flow control).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I avoid sending a repeated start between TWI write and TWI read?</title><link>https://devzone.nordicsemi.com/thread/77977?ContentTypeID=1</link><pubDate>Thu, 02 Mar 2017 06:47:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da10fe83-e249-44a0-8608-499ed688269a</guid><dc:creator>Iulian Mate?ica</dc:creator><description>&lt;p&gt;If you look in the MLX90614 datasheet at pages 14 and 15 you will see how the bus protocol looks like for a read or write. If you look closely you will notice that what you want for a sequential WRITE READ is to send a repeated start condition (the READ will produce it) but you do not want to to issue a stop condition after the WRITE.&lt;/p&gt;
&lt;p&gt;Your step 6 is wrong. You do want a start condition. What you don&amp;#39;t want is a stop one before de read.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I avoid sending a repeated start between TWI write and TWI read?</title><link>https://devzone.nordicsemi.com/thread/77976?ContentTypeID=1</link><pubDate>Wed, 01 Mar 2017 21:59:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac0a326b-0279-46ea-b56a-53b00656769b</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;I do not understand this answer!  The write function does not have a &amp;quot;no repeat start bit flag&amp;quot;! Here is the prototype, and as you can see, the flag is for either including or not including a stop at the end of the write transaction.  But, I have tried both setting and resetting the &amp;quot;no_stop&amp;quot; flag, and this has no affect on the repeated start:
ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance,
uint8_t               address,
uint8_t const *       p_data,
uint8_t               length,
bool                  no_stop);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I avoid sending a repeated start between TWI write and TWI read?</title><link>https://devzone.nordicsemi.com/thread/77975?ContentTypeID=1</link><pubDate>Tue, 28 Feb 2017 20:46:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b9e5bd9-f29c-4c42-94d8-84f2fe7dfdb6</guid><dc:creator>Iulian Mate?ica</dc:creator><description>&lt;p&gt;You can use the APP_TWI module. There you have the app_twi_perform function that gets a list of the twi tasks to execute. These tasks can be read or write, and they have the option not to issue the stop condition. You can have a list of tasks as follow:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;WRITE register address (set no_stop = true - after this write you don&amp;#39;t want to issue the stop condition because a READ will follow immediately).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;READ (this time no_stop should be set to false.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When you set no_stop = true for the Write operation instead of issuing the stop condition it will let the following Read issue its start condition. The stop condition has to be present at the end of this Read.
What version of the SDK do you have?&lt;/p&gt;
&lt;p&gt;At the end your secvention will look like this:&lt;/p&gt;
&lt;p&gt;START COND | ADDR + Write bit | REG ADDR | START COND | ADDR + Read bit |  | STOP COND.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I avoid sending a repeated start between TWI write and TWI read?</title><link>https://devzone.nordicsemi.com/thread/77974?ContentTypeID=1</link><pubDate>Tue, 28 Feb 2017 14:43:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fc25b6f-c774-466e-bc05-a7001ae647df</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;Ole,
I have not observed this to be sufficient; the repeated start is sent whether this parameter is set to &amp;quot;true&amp;quot; or reset to &amp;quot;false.  As the function parameter&amp;#39;s description states: 	&lt;/p&gt;
&lt;p&gt;&amp;quot;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).&amp;quot;&lt;/p&gt;
&lt;p&gt;What I need is the ability to start the &amp;quot;read&amp;quot; command without this command initiating another start.  Or perhaps I am thinking about this incorrectly.  Is there a way to transfer data packets from the slave device without using the &amp;quot;read&amp;quot; command; can the &amp;quot;write&amp;quot; command be used to get data back?&lt;/p&gt;
&lt;p&gt;A simpler solution would be the best, but I cannot find it and that is why I mentioned the GPIOTE - PPI approach.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I avoid sending a repeated start between TWI write and TWI read?</title><link>https://devzone.nordicsemi.com/thread/77973?ContentTypeID=1</link><pubDate>Tue, 28 Feb 2017 11:40:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbc81ad7-5b86-436d-963a-419b8b71da43</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Why don&amp;#39;t you use the driver in the SDK; nrf_drv_twi? If the no_stop flag in &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.2.0/group__nrf__drv__twi.html#ga2c5ea8408254dfa9cbff55dbee171a95"&gt;nrf_drv_tx(..)&lt;/a&gt; is false it should not issue a repeated start condition.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>