<?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>SAADC Sampling with a 3-axis Accelerometer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36451/saadc-sampling-with-a-3-axis-accelerometer</link><description>Hello, 
 I am currently trying to implement SAADC sampling from three channels into the same sample buffer (device is a 3-axis accelerometer, ADXL335). The root objective of my project is to read from three TWI sensors, one analog 3-output sensor (hence</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Aug 2018 11:06:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36451/saadc-sampling-with-a-3-axis-accelerometer" /><item><title>RE: SAADC Sampling with a 3-axis Accelerometer</title><link>https://devzone.nordicsemi.com/thread/142360?ContentTypeID=1</link><pubDate>Wed, 01 Aug 2018 11:06:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9562d869-9a6d-4f85-9c57-c9a4468ba409</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Hey Benjamin, sorry for the late reply.&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve got a hard time following your buffer set-up. The normal way is to just declare a buffer as an array of uint16&amp;#39;s :&lt;br /&gt;&lt;br /&gt;uint16_t adc_buffer[3];&lt;/p&gt;
&lt;p&gt;Set it to zero with a call to memset(&amp;amp;adc_buffer, 0, SAMPLES_IN_BUFFER);&lt;/p&gt;
&lt;p&gt;The SAADC will place the 14 bit samples as 16 bit unsigned intergers in a consecutive array of unsigned 16 bit integers. This means that adc_buffer[0] contains the x value, [1] contains the y value, and [2] contains the z value.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Since you&amp;#39;re reusing the buffer you need to cache the content between each sample:&lt;br /&gt;&lt;br /&gt;declare a uint16_t xyz_buffer;&lt;br /&gt;&lt;br /&gt;And copy the adc_buffer into the xyz_buffer in your adc event handler with a call to memcpy(&amp;amp;xyz_buffer, &amp;amp;adc_buffer, SAMPLES_IN_BUFFER);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>