<?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 example code for nrf5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74874/i2c-example-code-for-nrf5340</link><description>Hi , 
 my environment details: 
 
 nrf connect sdk 
 nrf5340 dk 
 segger embedded studio 
 
 I have seen I2C example code in below path 
 \v1.5.0\zephyr\samples\drivers\i2c_fujitsu_fram 
 please let me know where can I update I2C pin numbers (SDA and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 May 2021 14:12:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74874/i2c-example-code-for-nrf5340" /><item><title>RE: I2C example code for nrf5340</title><link>https://devzone.nordicsemi.com/thread/310206?ContentTypeID=1</link><pubDate>Tue, 18 May 2021 14:12:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:284235d5-4aa1-4b7a-a07d-c808ef1a6405</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p lang="en-GB"&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Hello,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p lang="en-GB"&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;have you configured the I2C peripheral accordingly for your nRF5340 target? Is the devicetree binding correct?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p lang="en-GB"&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Regarding your prj.conf, it should be enough to have the following two I2C commands in v1.5.0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p lang="en-GB"&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_I2C=y
CONFIG_NRFX_TWIM=y&lt;/pre&gt;&lt;/p&gt;
&lt;p lang="en-GB"&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p lang="en-GB"&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Markus&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example code for nrf5340</title><link>https://devzone.nordicsemi.com/thread/310003?ContentTypeID=1</link><pubDate>Tue, 18 May 2021 02:51:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:394cee81-1b16-4b5b-8343-4da655229a11</guid><dc:creator>SRINI</dc:creator><description>&lt;p&gt;Hi ,&lt;/p&gt;
&lt;p&gt;I have tested sensor module with nrf52832 using TWIM peripheral . it is working.&lt;/p&gt;
&lt;p&gt;I have tested sensor module with nrf5340 using TWIM peripheral . it is not working&lt;/p&gt;
&lt;p&gt;&amp;nbsp;please check below snippet code.&lt;/p&gt;
&lt;p&gt;uint8_t address = 0x6A;&lt;/p&gt;
&lt;p&gt;uint8_t reg = 0x0f;&lt;/p&gt;
&lt;p&gt;uint8_t reg_data = 0;&lt;/p&gt;
&lt;p&gt;nrfx_twim_t twim_instance = NRFX_TWIM_INSTANCE(2);&lt;/p&gt;
&lt;p&gt;nrfx_twim_config_t twim_config; &lt;br /&gt;&lt;span&gt;twim_config&lt;/span&gt;.scl = 10;&lt;br /&gt;&lt;span&gt;twim_config&lt;/span&gt;.sda = 9;&lt;br /&gt;&lt;span&gt;twim_config&lt;/span&gt;.frequency = NRF_TWIM_FREQ_100K;&lt;br /&gt;&lt;span&gt;twim_config&lt;/span&gt;.interrupt_priority = NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY;&lt;br /&gt;&lt;span&gt;twim_config&lt;/span&gt;.hold_bus_uninit = false;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;nrfx_twim_init(&amp;amp;&lt;span&gt;twim_instance&lt;/span&gt;, &amp;amp;&lt;span&gt;twim_config&lt;/span&gt;, &amp;amp;EventHandler, NULL);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;nrfx_twim_enable(&amp;amp;&lt;span&gt;twim_instance&lt;/span&gt;);&lt;/p&gt;
&lt;p&gt;nrfx_twim_xfer_desc_t const rx_xfer = NRFX_TWIM_XFER_DESC_TXRX(address, &amp;amp;reg, 1, &amp;amp;reg_data, 1);&lt;/p&gt;
&lt;p&gt;nrfx_twim_xfer(&amp;amp;&lt;span&gt;twim_instance&lt;/span&gt;, &amp;amp;rx_xfer, NRFX_TWIM_FLAG_REPEATED_XFER);&lt;/p&gt;
&lt;p&gt;expected output : 0x6C&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Actual output : 0x00&lt;/p&gt;
&lt;p&gt;Note: sensor module working tested with nrf52832 without any issues.&lt;/p&gt;
&lt;p&gt;please let me know the reason or if you have any tested code&amp;nbsp;with TWIM peripheral . please share to me.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;prj.conf file updated with below lines:&lt;/p&gt;
&lt;p&gt;CONFIG_I2C=y&lt;br /&gt;CONFIG_I2C_1=y&lt;br /&gt;CONFIG_NRFX_TWIM1=y&lt;br /&gt;&lt;strong&gt;CONFIG_NRFX_TWIM2=y&lt;/strong&gt;&lt;br /&gt;CONFIG_NRFX_TWIM3=y&lt;br /&gt;CONFIG_I2C_NRFX=y&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Srinivas.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example code for nrf5340</title><link>https://devzone.nordicsemi.com/thread/309322?ContentTypeID=1</link><pubDate>Tue, 11 May 2021 19:07:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f4f1785-c783-477a-9c53-4b11ec465c21</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p&gt;Actually, TWIM doesn’t act as an I2C. TWIM is the master peripheral of an I2C network. Please have a look at the &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF5340_PS_v1.1.pdf"&gt;product specification of the nRF5340&lt;/a&gt; on page 627.&lt;/p&gt;
&lt;p&gt;The I2C Fujitsu FRAM sample is written for a TWIM.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example code for nrf5340</title><link>https://devzone.nordicsemi.com/thread/309261?ContentTypeID=1</link><pubDate>Tue, 11 May 2021 12:59:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81033662-2ea2-46ac-93db-5167869ccd57</guid><dc:creator>SRINI</dc:creator><description>&lt;p&gt;Hi ,&lt;/p&gt;
&lt;p&gt;I have seen TWIM peripheral act as a i2c . Can I get any TWIM example code for nrf5340 .&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Srinivas.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example code for nrf5340</title><link>https://devzone.nordicsemi.com/thread/309245?ContentTypeID=1</link><pubDate>Tue, 11 May 2021 12:34:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a01647a-32c1-463c-8c21-f6174c9c9243</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p&gt;I would actually recommend the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/zephyr/samples/drivers/i2c_fujitsu_fram/README.html"&gt;I2C Fujitsu FRAM&lt;/a&gt; as a good example to start with.&lt;/p&gt;
&lt;p&gt;But since you already mentioned it, I guess it is not convenient to you?&lt;/p&gt;
&lt;p&gt;Another tip I can give you is to check the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/zephyr/reference/peripherals/i2c.html"&gt;I2C API&lt;/a&gt; in Zephyr, assuming you do not want to use the i2c_nrfx drivers directly.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example code for nrf5340</title><link>https://devzone.nordicsemi.com/thread/309107?ContentTypeID=1</link><pubDate>Tue, 11 May 2021 04:54:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a0e12e0-c6d4-46de-8c94-0d358bee9a12</guid><dc:creator>SRINI</dc:creator><description>&lt;p&gt;Hi ,&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t find any i2c configurations and i2c read and write operations.&amp;nbsp; I have seen sensor related function calls. Could you please provide me any i2c based sample application code for better understanding.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Srinivas.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example code for nrf5340</title><link>https://devzone.nordicsemi.com/thread/308897?ContentTypeID=1</link><pubDate>Mon, 10 May 2021 09:00:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5a62922-f563-44f9-b98d-34df8dbf2221</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p&gt;Hello Srinivas,&lt;/p&gt;
&lt;p&gt;You can find some sensor examples in .&lt;em&gt;./zephyr/samples/sensor&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;I would recommend you have a look at the BME280 sample. It includes overlay files in the board folder, which are used to connect the sensor to an I2C peripheral. With such an overlay file you can modify all attributes of each peripheral of your devicetree, such as updating the SDA/SCL pins.&lt;/p&gt;
&lt;p&gt;The syntax is the same as in &lt;em&gt;../bme280/&amp;lt;your_build_folder&amp;gt;/zephyr/zephyr.dts&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;If you want to read more about that, you can follow &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/zephyr/guides/dts/howtos.html#set-devicetree-overlays"&gt;this link&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/zephyr/guides/dts/howtos.html#set-devicetree-overlays"&gt;&lt;/a&gt;I hope this will help you!&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>