<?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>ADC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/90487/adc</link><description>hello 
 I try to make work the ADC on the NRF52840DK 
 I would like to use any of the 6 channels on the ARDUINO connector (p0.3, p0.4, p0.28-p0.31) 
 I am simply not able to make the code work. The only channel that works is channel 1. The project can</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 31 Oct 2022 16:53:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/90487/adc" /><item><title>RE: ADC</title><link>https://devzone.nordicsemi.com/thread/393318?ContentTypeID=1</link><pubDate>Mon, 31 Oct 2022 16:53:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fbc0f8c6-6e4a-421b-9f6d-9cadcdecf8b0</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;I found the Feather pinout in relation to the Nordic documentation confusing, so wrote this for the nRF52 SDK which may help&lt;/p&gt;
&lt;p&gt;(Edit: oops thought you were using Feather 840, not DK840)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define MAP(port, pin) (((port) &amp;lt;&amp;lt; 5) | ((pin) &amp;amp; 0x1F))
//                                                                           +------------------- Feather nRF52840 Board Assembly Pinout
//                                                                           |   +--------------- Feather nRF52840 BLE Module Pinout
//                                                                           |   |   +----------- Feather nRF52840 Arduino Pinout
//                                                                           |   |   |    +------ Internal Nordic nRF52840 Pinout
//                                                                           |   |   |    |
//                                                                           |   |   |    |        +--I/O Port &amp;#39;Q&amp;#39;-Quiet Signals Only
//                                          Feather                          |   |   |    |        |
//                                          Pin Id  Schematic Name         Pin Pin Pin  Pin  Name  |  Functions  Description
//                                          ======= =====================  === === ==== ==== ===== =  ========== ======================
#define PIN_XL1              MAP(0,  0) // &amp;quot; - X1   PIN_XL1&amp;quot;,               -  17  X1   D2   P0.00 -  XL1        Crystal 32.768kHz In
#define PIN_XL2              MAP(0,  1) // &amp;quot; - X2   PIN_XL2&amp;quot;,               -  18  X2   F2   P0.01 -  XL2        Crystal 32.768kHz Out
#define PIN_FEATHER_A4       MAP(0,  2) // &amp;quot; 9 A4   EPD_DC_PIN&amp;quot;,            9  11  A4   A12  P0.02 -  AIN0       Analog input 0
#define PIN_FEATHER_A5       MAP(0,  3) // &amp;quot;10 A5   EPD_CS_PIN&amp;quot;,           10   9  A5   B13  P0.03 -  AIN1       Analog input 1
#define PIN_FEATHER_A0       MAP(0,  4) // &amp;quot; 5 A0   -&amp;quot;,                     5  20  A0   J1   P0.04 -  AIN2       Analog input 2
#define PIN_FEATHER_A1       MAP(0,  5) // &amp;quot; 6 A1   -&amp;quot;,                     6  21  A1   K2   P0.05 -  AIN3       Analog input 3
#define PIN_FEATHER_D11      MAP(0,  6) // &amp;quot;23 D11  LED1_G&amp;quot;,               23  22  D11  L1   P0.06 -             D11
#define PIN_FEATHER_D6       MAP(0,  7) // &amp;quot;20 D6   PWM_OUTPUT_PIN_1&amp;quot;,     20  23  D6   M2   P0.07 -  TRACECLK   Trace clk Trace clock
#define PIN_FEATHER_D12      MAP(0,  8) // &amp;quot;24 D12  LED2_R&amp;quot;,               24  24  D12  N1   P0.08 -             D12
#define PIN_NFC1             MAP(0,  9) // &amp;quot; -  -   PIN_NFC1&amp;quot;,              -   -   -   L24  P0.09 -  NFC1       NFC antenna
#define PIN_NFC2             MAP(0, 10) // &amp;quot; -  -   PIN_NFC2&amp;quot;,              -   -   -   J24  P0.10 -  NFC2       NFC antenna
#define PIN_FEATHER_SCL      MAP(0, 11) // &amp;quot;18 SCL  -&amp;quot;,                    18  27  SCL  T2   P0.11 -  TRACEDATA2 Trace 2           SCL
#define PIN_FEATHER_SDA      MAP(0, 12) // &amp;quot;17 SDA  LED2_B&amp;quot;,               17  29  SDA  U1   P0.12 -  TRACEDATA1 Trace 1
#define PIN_FEATHER_MOSI     MAP(0, 13) // &amp;quot;12 MOSI SPIM_MOSI_PIN&amp;quot;,        12  37  MOSI AD8  P0.13 -
#define PIN_FEATHER_SCK      MAP(0, 14) // &amp;quot;11 SCK  SPIM_SCK_PIN&amp;quot;,         11  36  SCK  AC9  P0.14 -
#define PIN_FEATHER_MISO     MAP(0, 15) // &amp;quot;13 MISO -&amp;quot;,                    13  39  MISO AD10 P0.15 -
#define PIN_NEOPIXEL_RGB_LED MAP(0, 16) // &amp;quot; - NEO  PIN_NEOPIXEL_RGB_LED&amp;quot;,  -  38  NEO  AC11 P0.16 -             NEOPIXEL RGB LED
#define PIN_QSPI_FLASH_IO0   MAP(0, 17) // &amp;quot; - Q0   PIN_QSPI_FLASH_IO0&amp;quot;,    -  41  Q0   AD12 P0.17 -             QSPI D0  GD25Q16 16MBit FLASH
#define PIN_NRESET           MAP(0, 18) // &amp;quot; 1  -   PIN_NRESET&amp;quot;,            1  40   -   AC13 P0.18 -  nRESET     nRESET
#define PIN_QSPI_FLASH_SCK   MAP(0, 19) // &amp;quot; = QC   PIN_QSPI_FLASH_SCK&amp;quot;,    =  42  QC   AC15 P0.19 -             QSPI SCK GD25Q16 16MBit FLASH
#define PIN_QSPI_FLASH_CSN   MAP(0, 20) // &amp;quot; - QCS  PIN_QSPI_FLASH_CSN&amp;quot;,    -  44  QCS  AD16 P0.20 -             QSPI CS  GD25Q16 16MBit FLASH
#define PIN_QSPI_FLASH_IO3   MAP(0, 21) // &amp;quot; - Q3   PIN_QSPI_FLASH_IO3&amp;quot;,    -  43  Q3   AC17 P0.21 -             QSPI D3  GD25Q16 16MBit FLASH
#define PIN_QSPI_FLASH_IO1   MAP(0, 22) // &amp;quot; - Q1   PIN_QSPI_FLASH_IO1&amp;quot;,    -  46  Q1   AD18 P0.22 -             QSPI D1  GD25Q16 16MBit FLASH
#define PIN_QSPI_FLASH_IO2   MAP(0, 23) // &amp;quot; - Q2   PIN_QSPI_FLASH_IO2&amp;quot;,    -  45  Q2   AC19 P0.23 -             QSPI D2  GD25Q16 16MBit FLASH
#define PIN_FEATHER_RXD      MAP(0, 24) // &amp;quot;14 RXD  RX_PIN_NUMBER&amp;quot;,        14  48  RXD  AD20 P0.24 -             RXD
#define PIN_FEATHER_TXD      MAP(0, 25) // &amp;quot;15 TXD  TX_PIN_NUMBER&amp;quot;,        15  49  TXD  AC21 P0.25 -             TXD
#define PIN_FEATHER_D9       MAP(0, 26) // &amp;quot;21 D9   PWM_OUTPUT_PIN_0&amp;quot;,     21  19  D9   G1   P0.26 -
#define PIN_FEATHER_D10      MAP(0, 27) // &amp;quot;22 D10  -&amp;quot;,                    22  16  D10  H2   P0.27 -
#define PIN_FEATHER_A3       MAP(0, 28) // &amp;quot; 8 A3   EPD_RST_PIN&amp;quot;,           8  13  A3   B11  P0.28 -  AIN4       Analog input 4
#define PIN_VDIV             MAP(0, 29) // &amp;quot; = VDIV PIN_VDIV&amp;quot;,              =  10  VDIV A10  P0.29 -  AIN5       Analog input 5
#define PIN_FEATHER_A2       MAP(0, 30) // &amp;quot; 7 A2   EPD_BUSY_PIN&amp;quot;,          7  14  A2   B9   P0.30 -  AIN6       Analog input 6
#define PIN_FEATHER_AREF     MAP(0, 31) // &amp;quot; 3 AREF -&amp;quot;,                     3  12  AREF A8   P0.31 -  AIN7/AREF  Analog input 7
#define PIN_SWO              MAP(1,  0) // &amp;quot; - SWO  PIN_SWO&amp;quot;,               -  47  SWO  AD22 P1.00 -  TRACEDATA0 Trace 0   SWO
#define PIN_P1_01            MAP(1,  1) // &amp;quot; -  -   -&amp;quot;,                     -   -   -   Y23  P1.01 Q
#define PIN_SWITCH           MAP(1,  2) // &amp;quot; - SW   BUTTON_1&amp;quot;,              -  50  SW   W24  P1.02 Q             SWITCH
#define PIN_P1_03            MAP(1,  3) // &amp;quot; -  -   -&amp;quot;,                    59  V23   -   -   P1.03 Q
#define PIN_P1_04            MAP(1,  4) // &amp;quot; -  -   -&amp;quot;,                    60  U24   -   -   P1.04 Q
#define PIN_P1_05            MAP(1,  5) // &amp;quot; -  -   -&amp;quot;,                    48  T23   -   -   P1.05 Q
#define PIN_P1_06            MAP(1,  6) // &amp;quot; -  -   &amp;quot;,                     49  R24   -   -   P1.06 Q
#define PIN_P1_07            MAP(1,  7) // &amp;quot; -  -   -&amp;quot;,                    50  P23   -   -   P1.07 Q
#define PIN_FEATHER_D5       MAP(1,  8) // &amp;quot;19 D5   &amp;quot;,                     51  P2   19  D5   P1.08 -
#define PIN_FEATHER_D13      MAP(1,  9) // &amp;quot;25 D13  &amp;quot;,                     52  R1   25  D13  P1.09 -  TRACEDATA3 Trace 3
#define PIN_LED2_BLUE        MAP(1, 10) // &amp;quot; - LED2 PIN_LED2_BLUE&amp;quot;,        53  A20   -  LED2 P1.10 Q  Blue LED on board
#define PIN_P1_11            vAP(1, 11) // &amp;quot; -  -   -&amp;quot;,                    54  B19   -   -   P1.11 Q
#define PIN_P1_12            MAP(1, 12) // &amp;quot; -  -   -&amp;quot;,                    61  B17   -   -   P1.12 Q
#define PIN_P1_13            MAP(1, 13) // &amp;quot; -  -   -&amp;quot;,                    62  A16   -   -   P1.13 Q
#define PIN_P1_14            MAP(1, 14) // &amp;quot; -  -   -&amp;quot;,                    63  B15   -   -   P1.14 Q
#define PIN_LED1_RED         MAP(1, 15) // &amp;quot; - LED1 PIN_LED1_RED&amp;quot;          64  A14   -  LED1 P1.15 Q  Red LED on board&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC</title><link>https://devzone.nordicsemi.com/thread/393183?ContentTypeID=1</link><pubDate>Mon, 31 Oct 2022 09:53:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5d9bd80-a016-406e-a29e-0a28bba7b129</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;If you are using NCS, you would have to use Zephyr&amp;#39;s devicetree overlay to set the pin number. Here&amp;#39;s one that I have tested myself&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/ {
	zephyr,user {
		io-channels = &amp;lt;&amp;amp;adc 0&amp;gt;;
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here, you can use&amp;nbsp;&lt;code&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;adc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;&amp;gt;;&lt;/span&gt;&lt;/code&gt; replacing 0 with whatever pin number you want.&lt;/p&gt;
&lt;p&gt;In your code file, you can use these defines&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define ADC_CHANNEL          DT_IO_CHANNELS_INPUT_BY_IDX(DT_PATH(zephyr_user), 0)
#define ADC_NODE		     DT_PHANDLE(DT_PATH(zephyr_user), io_channels)
#define ADC_NUM_CHANNELS	 DT_PROP_LEN(DT_PATH(zephyr_user), io_channels)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can use the ADC example provided in NCS for the rest, as I used the same code on my side.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hope this helps&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC</title><link>https://devzone.nordicsemi.com/thread/379316?ContentTypeID=1</link><pubDate>Fri, 29 Jul 2022 12:23:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f396283d-7523-4609-aeb5-00611d11e21e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you provide more details on what is not working, and how you test the channels?&lt;/p&gt;
&lt;p&gt;I had a quick look at your workspace, but it is not that easy to find your ADC initialization and configuration in the code. Can you please post the relevant code here?&lt;/p&gt;
&lt;p&gt;Note that the configuration in Zephyr is relating to the AIN0-AIN7 pins, and not the A0-A5 Arduino markings on the DK. You can find the mappings from AIN to GPIO pin number in&amp;nbsp;&lt;a title="Pin assignments" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/pin.html?cp=4_0_0_6_0"&gt;Pin assignments&lt;/a&gt;&amp;nbsp;documentation.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>