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

which pin can be configured to analog input?

HI,EVERYONE,

in the document 'nRF51422_PS_v3.0.pdf' ,Page 167, there is such statement

'The selected analog pin will be acquired by the ADC when it is enabled through the ENABLE register, see GPIO chapter for more information on how analog pins are selected.'

Then in the Page 56, 14 General-Purpose Input/Output (GPIO),there is such statement

'• Analog input (for selected pins)'

but in the description of the register, there is no bit to config for the AIN pin.

So i do not know which can be configured for the ADC .

Following function is drived from nRF5_SDK_11.0.0-2.alpha_bc3f6a0\examples\peripheral\adc_simple

void adc_config(void)
{
    const nrf_adc_config_t nrf_adc_config = NRF_ADC_CONFIG_DEFAULT;

    // Initialize and configure ADC
    nrf_adc_configure( (nrf_adc_config_t *)&nrf_adc_config);
    nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_2);
    nrf_adc_int_enable(ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos);
    NVIC_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_HIGH);
    NVIC_EnableIRQ(ADC_IRQn);
}

Thank you.

  • Which pin is used is set in the PSEL field in the ADC config register. With the SDK driver this is done with

    nrf_adc_input_select(..)
    

    AIN0 to AIN7 can be used which corresponds to NRF_ADC_CONFIG_INPUT_0 to NRF_ADC_CONFIG_INPUT_7 in the SDK. Which pin numbers that corresponds to AIN0 to AIN7 can be seen in "pin assignments" chapter (2.2) in the Product Specification.

Related