<?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>SPI reading multiple register then concatenate</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/27992/spi-reading-multiple-register-then-concatenate</link><description>Hi, 
 I&amp;#39;m using the LSM6DS3 IMU using SPI.
I am able to read the WHO_AM_I register and retrieve the correct data with this code based on the spi example from the SDKv14.2.0 : 
 static uint8_t m_tx_buf[2]; /**&amp;lt; TX buffer. */
static uint8_t m_rx_buf</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 Jan 2019 07:32:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/27992/spi-reading-multiple-register-then-concatenate" /><item><title>RE: SPI reading multiple register then concatenate</title><link>https://devzone.nordicsemi.com/thread/167274?ContentTypeID=1</link><pubDate>Wed, 23 Jan 2019 07:32:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02ee7872-c7b6-4e38-9136-8e96c670151e</guid><dc:creator>Meera Shah</dc:creator><description>&lt;p&gt;What if I want to give a value to the particular register. for an e.g&lt;/p&gt;
&lt;p&gt;m_tx_buf[0] =&amp;nbsp;&lt;code&gt;(SPI_READ | LSM6DS3_OUTZ_L_XL );&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;m_tx_buf[1] = 0x01; //this could be any values then how it will &lt;span&gt;retrieve&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI reading multiple register then concatenate</title><link>https://devzone.nordicsemi.com/thread/110406?ContentTypeID=1</link><pubDate>Wed, 06 Dec 2017 21:05:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d9aa0ec-ebdd-4c6c-ac6b-957553aa1684</guid><dc:creator>StephaneJ</dc:creator><description>&lt;p&gt;This works very well ;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI reading multiple register then concatenate</title><link>https://devzone.nordicsemi.com/thread/110405?ContentTypeID=1</link><pubDate>Wed, 06 Dec 2017 20:18:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:433f4386-634c-40c3-a267-1b52fa09c670</guid><dc:creator>StephaneJ</dc:creator><description>&lt;p&gt;Thanks it seems to work well. I will dig deeper but the first results are encouraging. Thank you very much&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI reading multiple register then concatenate</title><link>https://devzone.nordicsemi.com/thread/110404?ContentTypeID=1</link><pubDate>Wed, 06 Dec 2017 20:09:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b91092f-ece0-4de8-998d-2d5a59398775</guid><dc:creator>Nathan</dc:creator><description>&lt;p&gt;According to that datasheet your IMU supports multi-byte read operations (end of section 6.2), which auto-increments the address with every byte clocked out. Make m_rx_buf 3 bytes long instead of 2, and modify the rx_length variable used by the nrf_drv_spi_transfer function to be 3. The last two bytes in the buffer are your LSB and MSB. So a simple blocking method you could rewrite for your purpose would be:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t outz_l_xl;
uint8_t outz_h_xl;
m_tx_buf[0] = (SPI_READ | LSM6DS3_OUTZ_L_XL );
rx_length = 3;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, 1, m_rx_buf, rx_length));

while (!spi_xfer_done) {}
outz_l_xl = m_rx_buf[1];
outz_h_xl = m_rx_buf[2];
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note however that depending on your specific device this may not be enough (I&amp;#39;m not going through the whole datasheet for you). Some IMUs have an automatic update lock feature so as long as the bus is busy the values won&amp;#39;t update. Others do not, in which case they usually have a FIFO you can take advantage of. As long as you don&amp;#39;t wait too long to read the values and blow the FIFO&amp;#39;s memory limit, each entry in the FIFO is guaranteed to be access safe, and is read using a multi byte access method.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>