<?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>Software I2C / switching I2C pins while runtime</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89851/software-i2c-switching-i2c-pins-while-runtime</link><description>Hello Nordic Team, We haven chosen a nRF52805 SoC and MDBT42T Module and would like to operate with 2 i2C sensors on two different Pin-pairs. Since the nRF52805 only has one i2c bus, i would like to use software i2c and use 2 different pin pairs or use</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 29 Jul 2022 14:33:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89851/software-i2c-switching-i2c-pins-while-runtime" /><item><title>RE: Software I2C / switching I2C pins while runtime</title><link>https://devzone.nordicsemi.com/thread/379351?ContentTypeID=1</link><pubDate>Fri, 29 Jul 2022 14:33:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1996455b-27e6-4179-a2a4-fb37777dc7fd</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;Hello Jonas,&lt;/p&gt;
&lt;p&gt;Thank you for the information. I will mark the ticket as closed then.&lt;br /&gt;In case of any other questions, please open a new ticket.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Michal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Software I2C / switching I2C pins while runtime</title><link>https://devzone.nordicsemi.com/thread/377643?ContentTypeID=1</link><pubDate>Tue, 19 Jul 2022 13:13:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acb153d0-cc97-4089-b66c-18464077302d</guid><dc:creator>JonasGel</dc:creator><description>&lt;p&gt;Thanks Michal,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I have tested dynamic pincontrol in SDK 2.0 but struggled a little with the implementation. &lt;br /&gt;And because it actually only should be used during startup, I&amp;nbsp;watched out for an alternative.&amp;nbsp;&lt;br /&gt;I Implemented it now successfully with the gpio-i2c driver and will later measure current consumption of this implementation against the hardware i2c-interface.&lt;/p&gt;
&lt;p&gt;(gpio-i2c driver:&amp;nbsp;&amp;nbsp;&lt;a id="" href="https://github.com/zephyrproject-rtos/zephyr/issues/27855"&gt;https://github.com/zephyrproject-rtos/zephyr/issues/27855&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Best Regards, Jonas&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Software I2C / switching I2C pins while runtime</title><link>https://devzone.nordicsemi.com/thread/376553?ContentTypeID=1</link><pubDate>Tue, 12 Jul 2022 08:38:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9bc33c8-94d2-4251-9269-734be84e32e7</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;Hello Jonas,&lt;/p&gt;
&lt;p&gt;The absolute easiest way would to be to put both sensors on one I2C bus. Even if it the exact same type of sensor, there is often a way to change the address by pulling a pin to either supply voltage or ground.&lt;/p&gt;
&lt;p&gt;If it is still not possible, then yes, it is possible to switch the I2C pins during runtime or use a software/bit-banging I2C implementation.&lt;/p&gt;
&lt;p&gt;I am going to assume that you are using NCS 2.0.0 and the new default Pin Control (pinctrl) API.&lt;br /&gt;Please remember to always state the version of NCS you are using so that we know which features are available to you.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;For hardware implementation you would have to use Dynamic Pin Control. Just remember to suspend the I2C peripheral before switching the pins.&lt;/p&gt;
&lt;p&gt;I would highly recommend reading the pinctrl documentation&lt;br /&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/nrf/ug_pinctrl.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/nrf/ug_pinctrl.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/hardware/pinctrl/index.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/hardware/pinctrl/index.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The second link includes a section about dynamic pin control:&lt;br /&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/hardware/pinctrl/index.html#dynamic-pin-control"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/hardware/pinctrl/index.html#dynamic-pin-control&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A sample utilizing dynamic control:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/samples/boards/nrf/dynamic_pinctrl/README.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/samples/boards/nrf/dynamic_pinctrl/README.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As for a software I2C, there was a driver in nRF5 SDK (components\drivers_nrf\twi_master\deprecated\twi_sw_master.c), but I don&amp;#39;t think we have any in NCS, so you would have to implement your own.&lt;/p&gt;
&lt;p&gt;Hope that answers your question.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Michal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>