<?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>Receiving 16 bits from TWI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44920/receiving-16-bits-from-twi</link><description>Hello, 
 I&amp;#39;m trying to receive a 2-byte data from a sensor from Maxim Integrated MAX31875 but the nrf_drv_twi_rx function only receive 8 bits data. Does this function to receive a 16 bits data exists or how can I change this function to receive a 16 bits</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Mar 2019 03:24:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44920/receiving-16-bits-from-twi" /><item><title>RE: Receiving 16 bits from TWI</title><link>https://devzone.nordicsemi.com/thread/176592?ContentTypeID=1</link><pubDate>Mon, 18 Mar 2019 03:24:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da419f3d-f8b7-426f-9375-8a21601e3036</guid><dc:creator>Laurent Bourassa</dc:creator><description>&lt;p&gt;What if you made your complete data a float type instead? I don&amp;#39;t know a lot about how floating points work but I think I&amp;#39;ve found something that might help you :&lt;/p&gt;
&lt;p&gt;&lt;a href="https://ryanstutorials.net/binary-tutorial/binary-floating-point.php"&gt;https://ryanstutorials.net/binary-tutorial/binary-floating-point.php&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving 16 bits from TWI</title><link>https://devzone.nordicsemi.com/thread/176591?ContentTypeID=1</link><pubDate>Mon, 18 Mar 2019 03:01:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e0af7a6-de62-4c38-bb5b-6460bdd2aee4</guid><dc:creator>Gabriel Bastos</dc:creator><description>&lt;p&gt;Awesome Laurent, thank you very much, this trick solved my problem! Do you know how can I change the bit LSB to have the (2^(1/256)) value ? , for example the normal LSB is 2^0 = 1 but I want the LSB values&amp;nbsp;&lt;span&gt;(2^(1/256)).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving 16 bits from TWI</title><link>https://devzone.nordicsemi.com/thread/176531?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 23:27:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d75312bb-5751-4004-9ea9-e3e03dc015ca</guid><dc:creator>Laurent Bourassa</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;I actually used type uint8_t to avoid confusion, this will specify the length of the variable to one byte exactly. Your variable should be an array of size 2.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t rx_buffer[2];

nrfx_twi_rx(&amp;amp;adc_twi,ADC_ADDR,&amp;amp;rx_buffer[0],sizeof(rx_buffer));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hence, once read, your data will be stored like this :&lt;/p&gt;
&lt;p&gt;rx_buffer[0] = first byte of data&lt;/p&gt;
&lt;p&gt;&lt;span&gt;rx_buffer[1] = second byte of data&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then you should be able to concatenate both&amp;nbsp;8 bits data into one 16 bits data like so :&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint16_t complete_data = ((uint16_t)rx_bufer[0] &amp;lt;&amp;lt; 8) | rx_buffer[1];&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I hope this better explains how I did it.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving 16 bits from TWI</title><link>https://devzone.nordicsemi.com/thread/176530?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 22:52:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7580bd85-c9ba-4b15-822c-46f45dc116c1</guid><dc:creator>Gabriel Bastos</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried but without sucess, I got zero as result. In fact, I was in doubt why you have used int as type of the variable, because this sizeof(int variable) is 4 byte and I want to have a 2 byte variable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving 16 bits from TWI</title><link>https://devzone.nordicsemi.com/thread/176488?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 15:29:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72b23759-c7e8-44c8-abab-3bb8a07b13ea</guid><dc:creator>Laurent Bourassa</dc:creator><description>&lt;p&gt;Put your received data in a int buffer of size 2 and in the lenght field of the read function, just write sizeof(rx_buffer).&lt;/p&gt;
&lt;p&gt;I have used a similar function like so :&lt;/p&gt;
&lt;p&gt;nrfx_twi_rx(&amp;amp;adc_twi,ADC_ADDR,&amp;amp;rx_buffer[0],sizeof(rx_buffer));&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>