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

Parents
  • Hi,

    I will assume you are using nRF51. Essentially you will need to configure EXTREFSEL with AREF1 and REFSEL with External. Something like this should work (I use hardware registers by preference).

    static void adc_init(void)
    {	
    	/* Enable interrupt on ADC sample ready event*/		
    	NRF_ADC->INTENSET = ADC_INTENSET_END_Msk;   
    	sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_LOW);  
    	sd_nvic_EnableIRQ(ADC_IRQn);
    	
    	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);							     /*!< 8bit ADC resolution. */ 
    	
    	/* Enable ADC*/
    	NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled;
    }
    

    This answer also contains some useful information.

    Best regards,

    Øyvind

  • I imagine the RC circuit was some kind of filter? It depends on your usecase, if you know you have noisy power lines then it might be a good idea. If you do have noisy power lines it might not be the best idea to use an external reference to start with.

Reply Children
No Data
Related