<?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>How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66572/how-to-configure-the-adc-periheral-in-the-device-tree-file-dts</link><description>Hello, 
 I am trying to figure out a way to configure the adc node using the .dts Device Tree file in a similar way to what is done for other nodes such as &amp;amp;spi and &amp;amp;i2c. 
 Unfortunately, all the examples I have seen so far only set the status property</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Oct 2020 18:47:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66572/how-to-configure-the-adc-periheral-in-the-device-tree-file-dts" /><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/275711?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 18:47:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f98fef2-28c2-42d5-8407-f41e3b4044f9</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;That is fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/275672?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 14:09:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6efbb6ed-b77e-4195-a88f-f383152866f0</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Mohamed,&lt;br /&gt;&lt;br /&gt;I see you are getting support with regards to this in this case:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/66702/build-zephyr-elf-versus-build-solution/275634#275634"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/66702/build-zephyr-elf-versus-build-solution/275634#275634&lt;/a&gt;&amp;nbsp;&lt;br /&gt;So lets us keep the discussion there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/275429?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2020 18:05:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad1a6a7f-5fb1-45f6-b9ae-e45bf8355b19</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;I give up. I tried few flavours of&amp;nbsp;the overlay file and none worked. The project always fail to load.&lt;/p&gt;
&lt;p&gt;# Method 1:&lt;br /&gt;&amp;amp;adc {&lt;br /&gt;# compatible = &amp;quot;nordic,nrf-saadc&amp;quot;;&lt;br /&gt;&amp;nbsp;compatible = &amp;quot;voltage-divider&amp;quot;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;adc5:adc@... {&lt;br /&gt;&amp;nbsp;label = &amp;quot;AIN_5&amp;quot;;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;adc7:adc@... {&lt;br /&gt;&amp;nbsp;label = &amp;quot;AIN_5&amp;quot;;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;n: node {&lt;br /&gt;&amp;nbsp;io-channels = &amp;lt;&amp;amp;adc5 26&amp;gt;, &amp;lt;&amp;amp;adc7 28&amp;gt;;&lt;br /&gt;&amp;nbsp;io-channel-names = &amp;quot;FOIL&amp;quot;, &amp;quot;STRAP&amp;quot;;&lt;br /&gt;&amp;nbsp;};&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;# Method 2:&lt;br /&gt;adc0: adc@4000E000 {&lt;br /&gt;compatible = &amp;quot;nordic,nrf-saadc&amp;quot;;&lt;br /&gt;# compatible = &amp;quot;voltage-divider&amp;quot;;&lt;br /&gt;label = &amp;quot;ADC_0&amp;quot;;&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;n: node {&lt;br /&gt;io-channels = &amp;lt;&amp;amp;adc0 4&amp;gt;;&lt;br /&gt;io-channel-names = &amp;quot;AIN_0&amp;quot;;&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;Mohamed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/272907?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2020 09:19:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5df05cba-dd2f-4ba5-ba85-d534cb4181c5</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;&lt;span&gt;Thank you.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;Please let me know which one is correct.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Kind&amp;nbsp;regards&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/272904?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2020 09:14:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d61613f4-d61f-4854-8692-5ee3729a1cf9</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Mohamed,&lt;br /&gt;You are correct, there seems to be some difference in the User guide and the Schematic.&lt;br /&gt;&lt;br /&gt;I will check this internally so it will be corrected.&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2577.pastedimage1601889241958v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Since the only inconsistency is the user guide, &lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;The correct Pin naming is the the schematic and the product spec&lt;/strong&gt;&lt;/span&gt;. which states: P0.04 is AIN0&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2500.pastedimage1601889881496v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/272782?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2020 15:34:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67892fda-c504-45b4-a1bb-81f55cfb0f9d</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;According to the PCA10095 schematics of the nRF5340 PDK&amp;nbsp; (nRF5340-QKAA) pin 4 on P0.04 is AIN0 not AIN1.&lt;/p&gt;
&lt;p&gt;Could you please double check. Thank you.&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;Mohamed&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/272745?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2020 13:11:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a19aa61-7321-4ee9-b001-c14093b23c89</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Learner,&lt;br /&gt;Yes, that should be correct.&lt;br /&gt;p0.04 of the nRF5340, so AIN1&lt;br /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7357.pastedimage1601644254110v1.png" alt=" " /&gt;&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf5340_pdk%2FUG%2Fnrf5340_PDK%2Fhw_analog_pins.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf5340_pdk%2FUG%2Fnrf5340_PDK%2Fhw_analog_pins.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/272608?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 15:56:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b2fd338-e048-498e-bfc2-d0983680b018</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;I have assumed that the number 4 in the line below is the pin number P0.04 which corresponds to adc channel AIN0. Is this right?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;io-channels = &amp;lt;&amp;amp;adc0 4&amp;gt;;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/272607?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 15:46:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd3b0518-0ec2-4586-bb77-6e25111b388f</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;In NCS Tutorial Part 2- the light intensity controller, there is this section of #defines for the ADC.&lt;/p&gt;
&lt;p&gt;/*ADC definitions and includes*/&lt;br /&gt;#include &amp;lt;hal/nrf_saadc.h&amp;gt;&lt;br /&gt;#define ADC_DEVICE_NAME DT_LABEL(DT_INST(0, nordic_nrf_saadc))&lt;br /&gt;#define ADC_RESOLUTION 10&lt;br /&gt;#define ADC_GAIN ADC_GAIN_1_6&lt;br /&gt;#define ADC_REFERENCE ADC_REF_INTERNAL&lt;br /&gt;#define ADC_ACQUISITION_TIME ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 10)&lt;br /&gt;&lt;strong&gt;#define ADC_1ST_CHANNEL_ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;#define ADC_1ST_CHANNEL_INPUT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NRF_SAADC_INPUT_AIN0&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Since I am configuring the adc channels using the .overlay with io-channels as you suggested file as follows,&lt;/p&gt;
&lt;p&gt;adc0: adc@4000E000 {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;label = &amp;quot;ADC_0&amp;quot;;&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;n: node {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;io-channels = &amp;lt;&amp;amp;adc0 4&amp;gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;io-channel-names = &amp;quot;AIN_0&amp;quot;&amp;quot;;&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;I think these two lines&amp;nbsp;are not needed anymore, am I right?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;#define ADC_1ST_CHANNEL_ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;#define ADC_1ST_CHANNEL_INPUT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NRF_SAADC_INPUT_AIN0&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But I am not sure how&amp;nbsp;the information in the .overlay file will get used by the C code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you please&amp;nbsp;advise on what changes I need to make to the C code to make it use the new info in the overlay file.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/272539?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 13:09:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27234158-443b-4e03-afda-a41256b20230</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Learner,&lt;br /&gt;&lt;br /&gt;Sounds good. Please let me know how it goes, or if you have some additional questions that come up.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/272485?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 10:57:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6016f02e-3085-49f2-969b-7d99f6831829</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;Thank you for your answer. I did go through the Tutorial Part 2 where the ADC is&amp;nbsp;NOT configured&amp;nbsp; via the .dts file.&amp;nbsp;So, the idea of using io-channels in the .dts file is what I am interested in. I have read some of it and I am not sure I get it. So, I am going to have a go at changing the sample of the light intensity controller in Tutorial 2 and use the .dts file and see if I can get it to work. I will probably need your help at some point to get it to work.&lt;/p&gt;
&lt;p&gt;Thank you for your support.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure the adc periheral in the Device Tree file *.dts</title><link>https://devzone.nordicsemi.com/thread/272466?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 09:37:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:703db4eb-72ef-4c01-8288-baa73df9256f</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi learner,&lt;br /&gt;&lt;br /&gt;In the &lt;a href="https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial---part-2-ncs-v1-3-0#h185sjwm5882m1bcimiad82dnf4kcy0b"&gt;NCS tutorial you can see how to add a ADC peripheral to your project.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;For the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/devicetree/index.html?c#adc" rel="noopener noreferrer" target="_blank"&gt;.dts you could use &amp;quot;io-channels&amp;quot; as shown here.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also here is a simple &lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/adc/src/main.c" rel="noopener noreferrer" target="_blank"&gt;unofficial ADC sample &lt;/a&gt;that may be of help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>