<?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 set a non-standard speed for the I2C bus using the Zephyr?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110306/how-can-i-set-a-non-standard-speed-for-the-i2c-bus-using-the-zephyr</link><description>Hi, 
 Using the Zephyr how can I set a TWI module clock frequency different from the standard speeds? 
 With nRF SDK I was able to do this by setting &amp;quot;frequency = 0x00290000UL&amp;quot;. 
 
 Using the Zephyr instead I only have the following speeds defined in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Sep 2024 12:07:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110306/how-can-i-set-a-non-standard-speed-for-the-i2c-bus-using-the-zephyr" /><item><title>RE: How can I set a non-standard speed for the I2C bus using the Zephyr?</title><link>https://devzone.nordicsemi.com/thread/503572?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2024 12:07:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51800d7e-b1b3-43f6-a7ad-e93773fb960f</guid><dc:creator>AlanIoT</dc:creator><description>&lt;p&gt;For future reference and to anyone who might be interested, I found quite an easy hack to change the i2c bitrate:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/108034/i2c-stops-working-on-nrf9160-dk-board-version-1-1-0-when-sw9-is-switched-to-non-default-3v-position/469344"&gt;this post&lt;/a&gt; explains a very easy hack to set the bitrate lower than 100kbps (Thank you &lt;a class="ui-contentpeek internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/burt" data-contentid="922b12f09b174828b067fb4e6d2a0b5e" data-contenttypeid="e9ed411860ed4f2ba0265705b8793d05"&gt;Burt&lt;/a&gt; !)&lt;/p&gt;
&lt;p&gt;Under `toolchainVersion &amp;gt; modules &amp;gt; hal &amp;gt; nordic &amp;gt; nrfx &amp;gt; mdk &amp;gt; nrf9160_bitfields.h` you can find the line&lt;/p&gt;
&lt;div style="background-color:#272822;color:#f8f8f2;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#f92672;"&gt;#define&lt;/span&gt;&lt;span style="color:#f8f8f2;"&gt; &lt;/span&gt;&lt;span style="color:#a6e22e;"&gt;TWIM_FREQUENCY_FREQUENCY_K100&lt;/span&gt;&lt;span style="color:#f8f8f2;"&gt; (&lt;/span&gt;&lt;span style="color:#f92672;"&gt;0x&lt;/span&gt;&lt;span style="color:#ae81ff;"&gt;01980000&lt;/span&gt;&lt;span style="color:#f92672;"&gt;UL&lt;/span&gt;&lt;span style="color:#f8f8f2;"&gt;)&lt;/span&gt;&lt;span style="color:#88846f;"&gt; /*!&amp;lt; 100 kbps */&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Simply changing this value according &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/391/uart-baudrate-register-values/2046"&gt;this instruction&lt;/a&gt; was the solution to our problem. So I set the value to 10 kbps&lt;/p&gt;
&lt;div style="background-color:#272822;color:#f8f8f2;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#f92672;"&gt;#define&lt;/span&gt;&lt;span style="color:#f8f8f2;"&gt; &lt;/span&gt;&lt;span style="color:#a6e22e;"&gt;TWIM_FREQUENCY_FREQUENCY_K100&lt;/span&gt;&lt;span style="color:#f8f8f2;"&gt; (&lt;/span&gt;&lt;span style="color:#f92672;"&gt;0x&lt;/span&gt;&lt;span style="color:#ae81ff;"&gt;0028F000&lt;/span&gt;&lt;span style="color:#f92672;"&gt;UL&lt;/span&gt;&lt;span style="color:#f8f8f2;"&gt;)&lt;/span&gt;&lt;span style="color:#88846f;"&gt; /*!&amp;lt; 100 kbps */&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;and here you can see that the SCL ticks are 100 &lt;span class="BxUVEf ILfuVd" lang="de"&gt;&lt;span class="hgKElc"&gt;&amp;micro;s long (= 10kbps) and the sensor responds now.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="BxUVEf ILfuVd" lang="de"&gt;&lt;span class="hgKElc"&gt;&lt;img style="cursor:zoom-in;max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1727178921565v1.png" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="BxUVEf ILfuVd" lang="de"&gt;&lt;span class="hgKElc"&gt;We are reading a sensor hanging on an 8 meter long cable, which is impossible without lowering the bitrate to a much lower value.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I set a non-standard speed for the I2C bus using the Zephyr?</title><link>https://devzone.nordicsemi.com/thread/490908?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2024 13:46:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f595830e-47c9-4283-8c3a-71b4f88469fb</guid><dc:creator>Stefano1984</dc:creator><description>&lt;p&gt;I solved it like this:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;((&lt;/span&gt;&lt;span&gt;NRF_TWIM_Type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span&gt;NRF_TWIM1_BASE&lt;/span&gt;&lt;span&gt;)-&amp;gt;&lt;/span&gt;&lt;span&gt;FREQUENCY&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0x00520000UL&lt;/span&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;I wrote directly in the register, now the I2C module has a frequency of 20 KHz.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I set a non-standard speed for the I2C bus using the Zephyr?</title><link>https://devzone.nordicsemi.com/thread/479527?ContentTypeID=1</link><pubDate>Thu, 18 Apr 2024 16:45:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3f7b191-fda0-4d95-bea4-17aee3af99b0</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;An option may be to use the nrfx api directly (instead of the zephyr api), see twi examples here:&lt;br /&gt;&lt;a href="https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src"&gt;https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you need to use the zephyr api I don&amp;#39;t see any other way than to modify the frequency register in between&amp;nbsp;device_is_ready() and before you execute any twi transfers.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>