ADC and Timer relationship in DUE

Well... that is weird. I saw this example, but last time I failed to implement it. This time it worked :slight_smile: It seems that Magician does have a bit of magic.

Anyway, I noticed my issue, perhaps you could explain this:

void ADC_Handler(void) {
	// if or while?
	if ((ADC->ADC_ISR & ADC_ISR_EOC7) && (ADC->ADC_ISR & ADC_ISR_EOC6)) {
		int val = *(ADC->ADC_CDR + 7);
		samples[currSample] = val;
		val = *(ADC->ADC_CDR + 6);
		samples2[currSample] = val;
		currSample += 1;
		if (currSample == sampleQty) {TC_Stop(TC0, 0);} 
	}
}

What is the difference there, where "if" is used and "while"? I mean, when I use "while", programs stops responding and stucks, but with "if" it seems to be working OK. What is the logic behind this facet? ADC interrupt is configured as this:

adc_enable_interrupt(ADC, ADC_IER_EOC7); // enable EOC7 interrupt.

Thanks.