Analogue input channel constants wrong in nrf52833_bitfields.h for nRF Connect SDK v3.2.1

I just upgraded my project (that runs on custom hardware with the nRF8233 using an Ezurio BL653 module) from nRF Connect SDK v3.1.0 to SDK v3.2.1 and the battery monitoring on my device stopped working with the following errors:

*** Using nRF Connect SDK v3.2.1-d8887f6f32df ***
*** Using Zephyr OS v4.2.99-ec78104f1569 ***
E: Cannot configure channel 0: -22
I: Setup AIN7 got -22
I: Battery setup: -22 0

It seems that the constants in nrf52833_bitfields.h have changed are are now out by 1, so the only way I can make it work is to change my device tree file from

    vbatt {
        compatible = "voltage-divider";
        io-channels = <&adc 7>;
        output-ohms = <180000>;
        full-ohms = <(1500000 + 180000)>;
     };
to
    vbatt {
        compatible = "voltage-divider";
        io-channels = <&adc 6>;
        output-ohms = <180000>;
        full-ohms = <(1500000 + 180000)>;
     };
Then it works and gives the correct voltages.
Why has this changed?
  • Hi Charles,

    I had some help here from a coworker that had the nRF52833 DK and compiled the same project for both 3.2.1 and 3.1.0 and they both run as expected here. Even built it for nRF52832 and running it on nRF52833 worked.

    Suspect that there's a board definition that you inherited that's present in the 3.2.1 version you are using. Would you be able to clean the project build and try again if it is something still of concern. 

    Best regards

    Asbjørn

  • Hi Asbjørn,

    I have done several clean builds and still get the same result. I'm not sure what you mean by "Suspect that there's a board definition that you inherited that's present in the 3.2.1 version you are using. " - I am just selecting "nrf52dk/nrf52832" in the "Edit Build configuration" for the "Board target" so it should be using the nRF52832 DK board files that come with the SDK and I expect them to be correct.

    When you tried what I described did you use <&adc 7> ? The problem only shows up with input 7.

    It appears to me that lots of changes have been made to the ADC driver and this problem is related to those changes.

    Thanks for your help, but I have already spent too much time on this and seeing as I have a work-around I'll leave it at that.

    regards,

    Charles

  • Hello Charles,
    Just for clarification, "Suspect that there's a board definition you inherited" I meant that it's not unlikely that some part of the build is bringing in wrong board definitions or configs by accident.
    Anyways, I'm glad you got it working and it is unfortunate that you spent time chasing this one down. Hopefully there has been some useful knowledge gained in additions for future.
    Best of luck and let us know if there should be any more questions.
    Asbjørn
  • Same here for the nRF9160. A VBATT stops working updating from 3.1.0 to 3.2.4.

    And also the same solution with using only  DT_IO_CHANNELS_INPUT(VBATT) without adding SAADC_CH_PSELP_PSELP_AnalogInput0.

    I guess, the change is in "modules/hal/nordic".

    Using the SAADC_EXTERNAL_AIN_PSELS of "nrfx_soc_defines.h" will fail, when adding SAADC_CH_PSELP_PSELP_AnalogInput0.

    Pretty nasty.

    Edited:

    nrfx 4.0 migration guide / saadc

Related