<?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>I2C Read instruction with unusual protocol</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80327/i2c-read-instruction-with-unusual-protocol</link><description>Hello, 
 I am using nRF52840 microcontroller to communicate with an external integrated circuit, through I2C peripheral . The project is using the latest Nordic SDK: more in detail, the library used for communication is nrf_drv_twi.c/.h (TWI used as master</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 Oct 2021 13:14:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80327/i2c-read-instruction-with-unusual-protocol" /><item><title>RE: I2C Read instruction with unusual protocol</title><link>https://devzone.nordicsemi.com/thread/332853?ContentTypeID=1</link><pubDate>Wed, 06 Oct 2021 13:14:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e300d529-3d86-47e1-97b1-3a075cc03807</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]The project is using the latest Nordic SDK: more in detail, the library used for communication is&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;nrf_drv_twi.c/.h&lt;/strong&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;(TWI used as&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;master&lt;/strong&gt;, based on SDK examples).[/quote]
&lt;p&gt;Which SDK example are you basing your application on?&lt;br /&gt;The TWI Scanner example uses the TWIM peripheral behind the scenes when the&amp;nbsp;TWI0_USE_EASY_DMA is defined to 1 - in which case all nrf_drv_twi calls are forwarded through macros to nrfx_twim calls. If you intend on using the TWI with easyDMA I recommend that you switch to using the nrfx_twim driver directly, instead of going through the forwarding from the legacy driver. If so, you could read about &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Ftwim.html&amp;amp;anchor=concept_ntg_svp_xr"&gt;the Master read sequence here&lt;/a&gt;, and you should instead then use &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Fgroup__nrfx__twim.html&amp;amp;anchor=gae53a1bebcd5961e1cd7a79e4039b8c88"&gt;the nrfx_twim_xfer function&lt;/a&gt;&amp;nbsp;for your transfers along with the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Fgroup__nrfx__twim.html&amp;amp;anchor=gaa87a3de9c2092f6d20c6d41bbfafd168"&gt;RX, TX macros&lt;/a&gt; for simplicity.&lt;/p&gt;
[quote user=""]&lt;p&gt;I can easily communicate to the slave I2C device with&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;write&lt;/strong&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;procedures.&lt;br /&gt;Instead, I have difficulties performing&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;read&lt;/strong&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;procedures since the protocol required by the slave device is as follows:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;That is peculiar. Are you using an official or third-party driver for your sensor?&lt;br /&gt;Does the driver list the registers&amp;#39; address twice - one for read and one for write - or only once, so that you have to indicate the read or write yourself?&lt;br /&gt;I have seen this done either way previously, unfortunately.&lt;/p&gt;
[quote user=""]I have tried using different combinations of&amp;nbsp;&lt;strong&gt;nrf_drv_twi_rx()&lt;/strong&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;strong&gt;nrf_drv_twi_tx()&lt;/strong&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;functions but I don&amp;#39;t get a byte sequence as the one in the figure above (checked with i2c sniffer).[/quote]
&lt;p&gt;Are you getting a NACK from your slave at any time, unexpectedly? If so, where in the transmission are you seeing this?&lt;br /&gt;Could you show me how your read commands currently look as seen by the sniffer?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>