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

Why I will restart the ADC is used to measure the voltage is greater than 1.2 V

Why I will restart the ADC is used to measure the voltage is greater than 1.2 V

void battery_start(void)
{
    uint32_t err_code;

    // Configure ADC
    NRF_ADC->INTENSET   = ADC_INTENSET_END_Msk;
    NRF_ADC->CONFIG     = ADC_CONFIG_RES_10bit << ADC_CONFIG_RES_Pos    |
                          ADC_CONFIG_INPSEL_AnalogInputNoPrescaling  << ADC_CONFIG_INPSEL_Pos |
                          ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos |
                          ADC_CONFIG_PSEL_AnalogInput3 << ADC_CONFIG_PSEL_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);
	//NVIC_SetPriority(ADC_IRQn,1);
	
    err_code = sd_nvic_EnableIRQ(ADC_IRQn);
    APP_ERROR_CHECK(err_code);
	//NVIC_EnableIRQ(ADC_IRQn);

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


    
    
}
Related