ADC ISR between threshold

I am using kl16 processor and I am using ADC peripheral as a part of my application. In ADC I want to write an ISR which has to get an interrupt when ADC value is between some threshold. So how can I do this? I tried the example code from codewarrior examples. But that gives interrupt when even 1 ADC sample also changed.

Please check chapter 2 of the following document: http://www.utasker.com/docs/uTasker/uTaskerADC.pdfIs this what you require to do?If so, it is available integrated in the uTasker project (as described) and also allows the operation to be simulated in the uTasker Kinetis simulator.

I do not quite understand "But that gives interrupt when even 1 ADC sample also changed."

The ADC module has this feature: Automatic compare with interrupt for less-than, greater-than or equal-to, within range, or out-of-range, programmable value.You can have a look at section "28.4.5 Automatic compare function" in KL16P80M48SF4RM:If the condition selected evaluates true, SC1n[COCO] is set. An ADC interrupt is generated when SC1n[COCO] is set and the respective ADC interrupt is enabled, that is, SC1n[AIEN]=1.