ADC channel changes from NCS 3.1.1 to NCS 3.2.0

Hi Nordic,

I'm using custom board based on nrf52840 SoC. After migrating the SDK, the original device tree configuration for ADC became unavailable, but I failed to find relevant explanations in the SDK migration guide. Through my own attempts, I modified the original dts that worked properly in ncs3.1.1 into a new dts, and it now works properly.
The old dts:

/ {
    vbatt {
        compatible = "voltage-divider";
        io-channels = <&adc 7>;
        output-ohms = <1000000>;
        full-ohms = <2000000>;
    };
};

&adc {
    status = "okay";
};

The new dts:

/ {
    vbatt {
        compatible = "voltage-divider";
        io-channels = <&adc 6>;
        output-ohms = <1000000>;
        full-ohms = <2000000>;
    };
};

&adc {
    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";
    channel@6 {
        reg = <6>;
        zephyr,gain = "ADC_GAIN_1_6";
        zephyr,reference = "ADC_REF_INTERNAL";
        zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
        zephyr,input-positive = <NRF_SAADC_AIN7>; /* P0.31 on nRF52840 */
        zephyr,resolution = <12>;
    };
};

These are two problems I encountered during my testing.

1.This error occurs during ADC setup when using channel 7 in NCS 3.2.0: <err> adc_nrfx_saadc: Cannot configure channel 0: -22. Normally, all 8 channels should be usable properly. I don't know why the error occurs in NCS 3.2.0.

2.If I do not use channel 6 but other channels such as channel 0 and channel 1, the voltage collected using adc_raw_to_millivolts(); will not be valid data. I do not see any other ADC channels being used in the final generated zephyr.dts, so I am not sure what exactly causes only channel 6 to be able to collect valid battery level data.

I hope you guys can answer my questions. Thank you very much.

Parents Reply Children
Related