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

ADC_IRQn trouble

I am having trouble with setting priority of ADC_IRQn.

void ADC_init(void)
{
nrf_adc_config_t nrf_adc_config;
nrf_adc_config.reference = NRF_ADC_CONFIG_REF_VBG;
nrf_adc_config.resolution = NRF_ADC_CONFIG_RES_8BIT;
nrf_adc_config.scaling = NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD;
nrf_adc_configure(&nrf_adc_config);
nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_DISABLED);
nrf_adc_int_enable(ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos);
sd_nvic_SetPriority(ADC_IRQn, 2);
sd_nvic_EnableIRQ(ADC_IRQn);
}

void ADC_init(void)
{
nrf_adc_config_t nrf_adc_config;
nrf_adc_config.reference = NRF_ADC_CONFIG_REF_VBG;
nrf_adc_config.resolution = NRF_ADC_CONFIG_RES_8BIT;
nrf_adc_config.scaling = NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD;
nrf_adc_configure(&nrf_adc_config);
nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_DISABLED);
nrf_adc_int_enable(ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos);
sd_nvic_SetPriority(ADC_IRQn, 2);
sd_nvic_EnableIRQ(ADC_IRQn);
}

static uint8_t adc_result = 0;

static void ADC_IRQHandler(void)
{
nrf_adc_conversion_event_clean();
adc_result = nrf_adc_result_get();
//isBattLow = (adc_result < 200);
isBattLow = true;
}

Both nrf_adc_start() and NRF_ADC->TASKS_START = 1 don't trigger ADC_IRQHandler() with above setting.

sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_LOW);
sd_nvic_SetPriority(ADC_IRQn, 3);
sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_HIGH);
sd_nvic_SetPriority(ADC_IRQn, 1);

Both nrf_adc_start() and NRF_ADC->TASKS_START = 1 make the system unresponsive with above 4 settings. I don't understand why it is happening.

Related