<?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>Simple I2C write example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61796/simple-i2c-write-example</link><description>I am looking for a simple example for I2C write. The TWI sensor example is not clear. 
 It would be great to have an example like the basic SPI example 
 i.e. 
 How to init the pins 
 How to write single byte 
 Thanks 
 Avi</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 May 2020 11:28:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61796/simple-i2c-write-example" /><item><title>RE: Simple I2C write example</title><link>https://devzone.nordicsemi.com/thread/251694?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 11:28:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc63b0fe-d887-418a-83ee-b5bf4478bcec</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t necessarily agree. I think the twi_sensor example is pretty straight forward:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can write a byte by calling &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__drv__twi.html#ga6c83eac2d358bc8fb5b53c53f22506b6"&gt;nrf_drv_twi_tx&lt;/a&gt;(). The parameters of the function are:
&lt;ul&gt;
&lt;li&gt;The twi instance&lt;/li&gt;
&lt;li&gt;The address that you&amp;#39;re writing to&lt;/li&gt;
&lt;li&gt;&amp;nbsp;The array that contains the data that you&amp;#39;re going to write&lt;/li&gt;
&lt;li&gt;The size of the array&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The initialization of pins are done in twi_init(). More specifically by setting SDA,SCL, twi frequency, and priority of the module in the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/structnrf__drv__twi__config__t.html"&gt;nrf_drv_twi_config_t &lt;/a&gt;struct.
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>