<?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>Write command for HRMI board using TWI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20000/write-command-for-hrmi-board-using-twi</link><description>Hello, 
 I am trying to implement a Heart Rate Monitor Interface (HRMI) board with my nRF52, using the TWI_sensor example from SDK 12.2. I am running into trouble Writing to commands to the peripheral I2C address. Here is the driver I have written to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 28 Feb 2017 00:02:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20000/write-command-for-hrmi-board-using-twi" /><item><title>RE: Write command for HRMI board using TWI</title><link>https://devzone.nordicsemi.com/thread/77821?ContentTypeID=1</link><pubDate>Tue, 28 Feb 2017 00:02:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3afc4c2-9d6f-48eb-8974-f2c43f821f27</guid><dc:creator>Levi</dc:creator><description>&lt;p&gt;Hi Jørgen,&lt;/p&gt;
&lt;p&gt;Thank you very much for the response. I have corrected my function as you suggested. However, I am still unable to read any heart rate values and it appears the the SDA and SCL lines are not communicating whatsoever. Can you help me with this?&lt;/p&gt;
&lt;p&gt;You have answered my original question so I will accept it, and I will go ahead and create a new question in the devzone for future use. New question &lt;a href="https://devzone.nordicsemi.com/question/117820/twi-not-working-for-hrmi-using-nrf52/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thank you very much!&lt;/p&gt;
&lt;p&gt;Levi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Write command for HRMI board using TWI</title><link>https://devzone.nordicsemi.com/thread/77820?ContentTypeID=1</link><pubDate>Mon, 27 Feb 2017 14:04:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:574cff85-b59e-49dc-a523-8cbf8d592062</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;From the data sheet is see the following statement:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Commands and arguments are encoded as
8-bit binary values. Command Sequences
consist of 1- or 2-byte I2C write
sequences (the command byte followed
by any required argument byte)
followed by the STOP condition.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is not different from the TWI examples in our SDK. However, your &lt;code&gt;start_HR()&lt;/code&gt; function does not look entirely correct.&lt;/p&gt;
&lt;p&gt;You set the &lt;code&gt;length&lt;/code&gt; parameter of the &lt;code&gt;nrf_drv_twi_tx()&lt;/code&gt; function to 3, but you only pass a 1-byte  variable to argument &lt;code&gt;p_data&lt;/code&gt;. If I understand you correctly, you want to send &amp;lt;0x47&amp;gt;&amp;lt;0x03&amp;gt; to get 3 HR values? This can be done like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ret_code_t start_HR(uint8_t num_samples) 
{
	ret_code_t ret_code;
	uint8_t reg[2] = {HRMI_GET_HR_DATA, num_samples}; // &amp;lt;0x47&amp;gt;
	ret_code = nrf_drv_twi_tx(&amp;amp;m_twi, HRMI_I2C_ADDR, reg, sizeof(reg), false);
	return ret_code;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then call the function with the number of samples you want:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;start_HR(0x03);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>