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

About adc conversion voltage problems

I use direct input AIN2 pin battery 3.3v, the other pins are not connected to anything, I did not enter into ADC_IRQHandler,may ask about what the problem it

this is my code :

#define adc_PIN_NUMBER 1

NRF_ADC->INTENSET = ADC_INTENSET_END_Msk; NRF_ADC->CONFIG = (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos)
| (ADC_CONFIG_PSEL_AnalogInput2 << ADC_CONFIG_PSEL_Pos)
| (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos)
| (ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos)
| (ADC_CONFIG_RES_10bit << ADC_CONFIG_RES_Pos);
NRF_ADC->EVENTS_END = 0; NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled;

// Enable ADC interrupt
err_code = sd_nvic_ClearPendingIRQ(ADC_IRQn);
APP_ERROR_CHECK(err_code);

err_code = sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_LOW);
APP_ERROR_CHECK(err_code);

err_code = sd_nvic_EnableIRQ(ADC_IRQn);
APP_ERROR_CHECK(err_code);

NRF_ADC->EVENTS_END  = 0;    // Stop any running conversions.
NRF_ADC->TASKS_START = 1;

nrf_gpio_cfg_input(adc_PIN_NUMBER , NRF_GPIO_PIN_PULLDOWN);

Related