<?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>iic can&amp;#39;t read data but can write data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104188/iic-can-t-read-data-but-can-write-data</link><description>Hi , I have some questions about i2c when I use 
 i2c_write_read_dt (&amp;amp;dev_i2c,&amp;amp;config[ 0 ], 1 ,&amp;amp;config[ 1 ], 1 ); 
 The data cannot be read correctly , 
 i2c_burst_read_dt (&amp;amp;dev_i2c, 0x08 ,temp_reading, sizeof (temp_reading)); 
 The data read will be</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Oct 2023 09:23:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104188/iic-can-t-read-data-but-can-write-data" /><item><title>RE: iic can't read data but can write data</title><link>https://devzone.nordicsemi.com/thread/449313?ContentTypeID=1</link><pubDate>Mon, 09 Oct 2023 09:23:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d5f83f1-a5f6-4d91-9116-a58d7e0972da</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;In the last three entries, what did you expect to read out? How exactly is it not correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iic can't read data but can write data</title><link>https://devzone.nordicsemi.com/thread/449115?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2023 05:40:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b11f97fb-5e12-45e4-8a4c-251720372886</guid><dc:creator>refix</dc:creator><description>&lt;p&gt;I have tried to read it individually, but if I read only one piece of data, most of it will not be useful data. In the continuous reading mode, I can read the data, but the first complement will not be correct. Just like I read the last three entries above, but only the last two entries are correct.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1696570909202v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iic can't read data but can write data</title><link>https://devzone.nordicsemi.com/thread/448963?ContentTypeID=1</link><pubDate>Thu, 05 Oct 2023 09:50:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f10f938-59af-4990-b619-b8b23af7fa51</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you tried just doing a separate read&amp;nbsp;without any write before?&lt;/p&gt;
&lt;p&gt;Are you able to read any other register from the slave?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iic can't read data but can write data</title><link>https://devzone.nordicsemi.com/thread/448854?ContentTypeID=1</link><pubDate>Wed, 04 Oct 2023 14:15:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34ac0b43-d0f7-4750-b1e7-1a7f0e53da77</guid><dc:creator>refix</dc:creator><description>&lt;p&gt;I think you are right but I don&amp;#39;t know if Ruhe should wait for ACK when reading and then read the library I use is &amp;lt;zephyr/drivers/i2c.h&amp;gt;&lt;/p&gt;
&lt;p&gt;overlay&amp;nbsp;&lt;/p&gt;
&lt;p&gt;```&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;i2c1&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;clock-frequency&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &amp;lt;&lt;/span&gt;&lt;span&gt;I2C_BITRATE_FAST_PLUS&lt;/span&gt;&lt;span&gt;&amp;gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;mysensor:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;mysensor&lt;/span&gt;&lt;span&gt;@&lt;/span&gt;&lt;span&gt;40&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;compatible&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;quot;i2c-device&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;status&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;quot;okay&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;reg&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &amp;lt; &lt;/span&gt;&lt;span&gt;0x40&lt;/span&gt;&lt;span&gt; &amp;gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; };&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;};&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;```&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;regards&lt;br /&gt;refix&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iic can't read data but can write data</title><link>https://devzone.nordicsemi.com/thread/448756?ContentTypeID=1</link><pubDate>Wed, 04 Oct 2023 07:46:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b188b403-5a5c-4d76-b9e1-16b414749c02</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;It looks like you&amp;#39;re trying to write and then read out the same register from the I2C slave, is this correct?&lt;/p&gt;
&lt;p&gt;It seems like the write is successful, but the slave return a NACK when you try to read out the same register later here:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1696405526955v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;From the nRF5340 perspective it looks correct. Maybe you need to wait some time before you can read out the register after writing. The read process should be specified in the datasheet of the slave device,&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iic can't read data but can write data</title><link>https://devzone.nordicsemi.com/thread/448693?ContentTypeID=1</link><pubDate>Tue, 03 Oct 2023 16:35:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17503458-a551-474b-a635-967590bb631b</guid><dc:creator>refix</dc:creator><description>&lt;p&gt;sure I think I requesting the correct read address.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1696350877155v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;and this picture is from MAX30210EVKIT Sensor Evaluation Kit data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;regards&lt;br /&gt;refix&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iic can't read data but can write data</title><link>https://devzone.nordicsemi.com/thread/448667?ContentTypeID=1</link><pubDate>Tue, 03 Oct 2023 13:22:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f10ad98-1a06-4284-851d-5f8897fae505</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure why mean by the data being shifted but looking at the original data trace that you shared:&lt;/p&gt;
[quote user=""]&lt;div&gt;&lt;div&gt;&lt;span&gt;&lt;time datetime="2023-09-26T16:44:50.572Z"&gt;&lt;span&gt;編輯)&lt;/span&gt;&lt;/time&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;img style="max-height:240px;max-width:320px;cursor:zoom-in;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/7633.pastedimage1695756404959v1.png" alt=" " /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;[/quote]
&lt;p&gt;It looks like the peripheral is sending a NACK after the read request.&lt;/p&gt;
&lt;p&gt;Are you sure that you&amp;#39;re requesting the correct read address to the slave?&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iic can't read data but can write data</title><link>https://devzone.nordicsemi.com/thread/448523?ContentTypeID=1</link><pubDate>Mon, 02 Oct 2023 13:11:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdcb5d56-f885-4219-b61b-94d0bcdfee77</guid><dc:creator>refix</dc:creator><description>&lt;p&gt;yes&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1696252249465v7.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:0px;max-width:0px;" src="https://devzone.nordicsemi.com/resized-image/__size/0x0/__key/communityserver-discussions-components-files/4/pastedimage1696252155277v3.png" alt=" " /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1696252227093v6.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1696252183951v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1696252205467v5.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1696252283392v8.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iic can't read data but can write data</title><link>https://devzone.nordicsemi.com/thread/447972?ContentTypeID=1</link><pubDate>Wed, 27 Sep 2023 13:42:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc5bf7d5-894a-438d-be26-8672f708fe83</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]&lt;div&gt;&lt;div&gt;&lt;span&gt;The data read will be shifted&lt;/span&gt;&lt;span&gt;. I use nrf5340 audio dk to control max&lt;/span&gt;&lt;span&gt;3&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;2&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;. How can I fix this&lt;/span&gt;&lt;span&gt;?&lt;/span&gt; &lt;span&gt;&lt;time datetime="2023-09-26T16:44:50.572Z"&gt;&lt;span&gt;(已編輯)&lt;/span&gt;&lt;/time&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;img style="max-height:240px;max-width:320px;cursor:zoom-in;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/3755.pastedimage1695756404959v1.png" alt=" " /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;[/quote]
&lt;p&gt;That sounds very strange, could you share a full trace from the logical analyzer?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>