Hello,

I’m working on a project that requires multiple ADC channels. I followed this example and got ADC_0 working. However, after compiling, according to the device tree file zephyr.dts, only "ADC_0" is configured automatically:

adc: adc@e000 {
	compatible = "nordic,nrf-saadc";
	reg = < 0xe000 0x1000 >;
	interrupts = < 0xe 0x1 >;
	status = "okay";
	label = "ADC_0";
	#io-channel-cells = < 0x1 >;
	phandle = < 0x4 >;
};

Following the example to set CONFIG_ADC_5 in prj.conf didn’t work

CONFIG_ADC=y
CONFIG_ADC_5=y
CONFIG_ADC_NRFX_SAADC=y

Using these configs in prj.conf will return

/home/nfed/prj.conf:60: warning: attempt to assign the value 'y' to the undefined symbol ADC_5

I wonder how do I enable other ADC channels? Is it possible to do it through the .overlay file?

Thank you

Ron Zeman

    Hey ronzeman

    There is only one ADC on the nRF9160. The channels however configure which input you’d like to use. So for instance, the battery measurement is connected to P0.20/AIN7 (channel 7). All the A pins correspond to the analog channel numbers except for P0.19/SCK (that pin is also channel 6)

    You can see that the channel is indicated in the io-channels array list in the device tree common file:

    	vbatt {
    		compatible = "voltage-divider";
    		io-channels = <&adc 7>;
    		output-ohms = <100000>;
    		full-ohms = <(100000 + 100000)>;
    		power-gpios = <&gpio0 25 0>;
    	};

    You may want to check out the battery sample in NFED on how it uses the ADC and initializes a channel. You may need to create a new binding for your specific application. Here is the one for voltage-divider (search for voltage-divider.yml):

    # Copyright (c) 2019, Peter Bigot Consulting, LLC
    # SPDX-License-Identifier: Apache-2.0
    
    description: |
        Description for a voltage divider, with optional ability to measure
        resistance of the upper leg.
    
    compatible: "voltage-divider"
    
    include: base.yaml
    
    properties:
        io-channels:
          required: true
          description: |
            Channels available with this divider configuration.
    
        output-ohms:
          type: int
          required: true
          description: |
            Resistance of the lower leg of the voltage divider
    
        full-ohms:
          type: int
          required: false
          description: |
            Resistance of the full path through the voltage divider.
    
            If absent or zero the driver assumes that the upper leg is a
            resistance-based sensor.
    
        power-gpios:
          type: phandle-array
          required: false
          description: |
            Control power to the voltage divider inputs.
    
            If present the corresponding GPIO must be set to an active level
            to enable the divider input.

    I hope that helps.

    Terms and Conditions | Privacy Policy