This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Use AREF1(pin0.06) as analog reference voltage for ADC instead of internal VBG

Dear Sir: Could I use the external reference AREF1(pin0.06) instead of internal VBG 1.2V for ADC operation ? I do the following settings to config using external reference

   nrf_adc_config.resolution = NRF_ADC_CONFIG_RES_10BIT;
   nrf_adc_config.scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE;
   nrf_adc_config.reference = NRF_ADC_CONFIG_REF_EXT_REF1;

But it doesn't work, is there any other settings before using external reference for ADC.

Thanks a lot

  • Hi: I use the following setting as you recommanded, the voltage value I read is 1.013V, But the real value is 0.9V. And when I use internal 1.2V as reference voltage ,the value I get is close to 0.9V.

    NRF_ADC->CONFIG = (ADC_CONFIG_EXTREFSEL_AnalogReference1 << ADC_CONFIG_EXTREFSEL_Pos) /* Bits 17..16 : ADC external reference pin selection. */
                        | (ADC_CONFIG_PSEL_AnalogInput2 << ADC_CONFIG_PSEL_Pos)                      /*!< Use analog input 2 as analog input. */
                        | (ADC_CONFIG_REFSEL_External << ADC_CONFIG_REFSEL_Pos)                      /*!< Use external voltage as reference for conversion. */
                        | (ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) /*!< Analog input specified by PSEL with no prescaling used as input for the conversion. */
                        | (ADC_CONFIG_RES_10bit << ADC_CONFIG_RES_Pos);
    
  • Were you able to get any readings with the previous code?

  • By the way, be sure to adjust the scaling, in the code I provided I had set ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling, but this might not be right for your applciation, you need to tweak around with this.

  • Yes, I try to change ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling to ADC_CONFIG_INPSEL_AnalogInputNoPrescaling, but the voltage I read is also larger than 1.0V. The "previous code "you mentioned is my own code ? Yes, I can get value by the following code

    void mp_adc_config(void)
    {    
        nrf_adc_config_t nrf_adc_config = NRF_ADC_CONFIG_DEFAULT;
    
    		nrf_adc_config.resolution = NRF_ADC_CONFIG_RES_10BIT;
    		nrf_adc_config.scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE;
    		nrf_adc_config.reference = NRF_ADC_CONFIG_REF_EXT_REF1;
    
        nrf_adc_configure( (nrf_adc_config_t *)&nrf_adc_config);
    
        nrf_adc_int_enable(ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos);  /*!< Interrupt enabled. */
        NVIC_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_HIGH);   //Configure the priority
        NVIC_EnableIRQ(ADC_IRQn);
    	
    		mp_adc_init();
    
    		nrf_adc_input_select(g_mpADC[MP_ADC_INDEX_TEMP].channel);
    }
    
  • Ah, then I understand. I thought you were not getting any output, my bad.

    Referring to the product specification the ADC will get less accurate for lower voltages, with specificed 3 LSB error at 1V8, I think this may increase if the voltage decreases further. The 1.013V you see is likely within specifications of the ADC device.

    As you suggested earlier you can try to add a reservoir capacitor to the AREF port and see if this improves things.

    Best regards,

    Øyvind

Related