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

Proximity app ADC Input

I am using nRF51422 with the SDK 11.  I am using the proximity application to measure the battery service.  By default, the device uses VDD as its ADC input.  I would like to change the input to another available pin (for example p0.00).  How would I be able to do this?

Parents
  • Hello,

    ...

    I assume you mean the ADC uses VDD as the ADC voltage reference?


    From the Proximity Application's main.c:

    /**@brief Function for configuring ADC to do battery level conversion.
     */
    static void adc_configure(void)
    {
        #ifdef NRF51
        ret_code_t err_code = nrf_drv_adc_init(NULL, adc_event_handler);
        APP_ERROR_CHECK(err_code);
    
        static nrf_drv_adc_channel_t channel = NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_DISABLED);
        //channel.config.config.input = NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD;
        channel.config.config.input = (uint32_t)NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD;
        nrf_drv_adc_channel_enable(&channel);
    
        err_code = nrf_drv_adc_buffer_convert(&adc_buf[0], 1);
        APP_ERROR_CHECK(err_code);
    }

    This is where the ADC is configured using the ADC HW driver. You must change NRF_ADC_CONFIG_INPUT_DISABLED to wanted channel.

    static nrf_drv_adc_channel_t channel = NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_DISABLED);

    More information about the ADC driver can be found here. The channels that are available for the ADC can be found here. Be aware that AIN0 (P0.00) is ADC/LPCOMP reference input. Please read the nRF51422 Reference Manual chapter 31 Analog to Digital Converter (ADC) to ensure correct usage. Please have a look at this document .

    Kind regards,
    Oeyvind

Reply
  • Hello,

    ...

    I assume you mean the ADC uses VDD as the ADC voltage reference?


    From the Proximity Application's main.c:

    /**@brief Function for configuring ADC to do battery level conversion.
     */
    static void adc_configure(void)
    {
        #ifdef NRF51
        ret_code_t err_code = nrf_drv_adc_init(NULL, adc_event_handler);
        APP_ERROR_CHECK(err_code);
    
        static nrf_drv_adc_channel_t channel = NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_DISABLED);
        //channel.config.config.input = NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD;
        channel.config.config.input = (uint32_t)NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD;
        nrf_drv_adc_channel_enable(&channel);
    
        err_code = nrf_drv_adc_buffer_convert(&adc_buf[0], 1);
        APP_ERROR_CHECK(err_code);
    }

    This is where the ADC is configured using the ADC HW driver. You must change NRF_ADC_CONFIG_INPUT_DISABLED to wanted channel.

    static nrf_drv_adc_channel_t channel = NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_DISABLED);

    More information about the ADC driver can be found here. The channels that are available for the ADC can be found here. Be aware that AIN0 (P0.00) is ADC/LPCOMP reference input. Please read the nRF51422 Reference Manual chapter 31 Analog to Digital Converter (ADC) to ensure correct usage. Please have a look at this document .

    Kind regards,
    Oeyvind

Children
No Data
Related