cancel
Showing results for 
Search instead for 
Did you mean: 

Interruption, but corresponding interrupt flag is not set?

ZJing
Associate III

Dear community,

I am having a strange problem with the STM32L431.

The ADC is set up for use with both the DMA and interruption. This is to de-interleave the adc results from 2 different channels, since there was problem with interleaved ADC results when only using DMA -- The order of ADC results in the DMA buffer would get messed up after running for a while for some unknown reason, so it was impossible to tell which result is from which channel. Therefore, I changed my code and started to use the ADC with DMA and interruption together.

Part of current ADC initializing code:

	adc_reg_config.Channel = ADC_CHANNEL_1;
	adc_reg_config.Rank = ADC_REGULAR_RANK_1;
	adc_reg_config.SingleDiff = ADC_DIFFERENTIAL_ENDED;
	adc_reg_config.SamplingTime = ADC_SAMPLETIME_24CYCLES_5;
 
	HAL_ADC_ConfigChannel(p_adc_handle, &adc_reg_config);
 
	adc_inj_config.InjectedChannel = ADC_CHANNEL_VREFINT;
	adc_inj_config.InjectedRank = ADC_INJECTED_RANK_1;
	adc_inj_config.InjectedSamplingTime = ADC_SAMPLETIME_24CYCLES_5;
	adc_inj_config.InjectedSingleDiff = ADC_SINGLE_ENDED;
	adc_inj_config.InjectedNbrOfConversion = 1;
	adc_inj_config.AutoInjectedConv = ENABLE;
	adc_inj_config.ExternalTrigInjecConv = ADC_INJECTED_SOFTWARE_START;
	adc_inj_config.InjecOversamplingMode = ENABLE;
	adc_inj_config.InjecOversampling = adc_inj_osp_config;
	
	HAL_ADCEx_InjectedConfigChannel(p_adc_handle, &adc_inj_config);
	
	HAL_ADCEx_Calibration_Start(p_adc_handle, ADC_DIFFERENTIAL_ENDED);
	HAL_ADCEx_Calibration_Start(p_adc_handle, ADC_SINGLE_ENDED);
 
	LL_ADC_EnableIT_JEOC(p_adc_handle->Instance);
	LL_ADC_EnableIT_OVR(p_adc_handle->Instance);
	LL_ADC_DisableIT_JEOS(p_adc_handle->Instance);
	LL_ADC_DisableIT_JQOVF(p_adc_handle->Instance);
	LL_ADC_DisableIT_EOC(p_adc_handle->Instance);
	LL_ADC_DisableIT_EOS(p_adc_handle->Instance);
	LL_ADC_DisableIT_EOSMP(p_adc_handle->Instance);
	LL_ADC_DisableIT_ADRDY(p_adc_handle->Instance);
	
	HAL_NVIC_EnableIRQ(ADC1_IRQn);
 
	HAL_ADC_Start_DMA(p_adc_handle, (uint32_t*)reg_buf, BL);

Problem: I get interrupt, but none of the two enabled ADC interrupt flag (JEOC and OVR) is set.

Enabled interrupts:0693W00000UoSQbQAN.pngThis breakpoint is reached once in a while (which means that there is ADC interruption, but neither the JEOC nor the OVR flag is set, right?)

0693W00000UoSQqQAN.png 

Please help! Thanks in advance!

10 REPLIES 10

Hi JW,

I see. Well, is using if(LL_ADC_IsActiveFlag_JEOC(ADC1)) to guard the ISR very safe? That is, will the situation that the NVIC is not cleared (so program enters ISR for the second time), and the JEOC flag does not get cleared either, ever happen?

I guess the real question is, how much time does it take to clear the interrupt specific JEOC flag, compared to the general interrupt flag (NVIC?)

Regarding the APB bus and ADC clocks: I assume that the APB bus should not add extra delay to this interrupt flag clearing process, since it is the same as main clock, but the ADC clock will add to the delay, since it is asynchronous to the main clock? Is this correct?

Again, thank you very much for helping!