ADC ISR between threshold

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC ISR between threshold

1,327 Views
yasararafathcs
Contributor II

Hi All,

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.

Anyone has idea on this?

Thanks & Regards,

Yasar Arafath

0 Kudos
4 Replies

783 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Yasar Arafath,

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.

Compare modes.png

I recommend you using Kinetis Design Studio IDE.  CodeWarrior IDE Support to Change for Kinetis® Devices. Read More

The interrupt example of adc16 in SDK_2.0_MKL16Z256xxx4 can be used to evaluate automatic compare function.

SDK_2.0_MKL16Z256xxx4.png

You just need add ADC16_SetHardwareCompareConfig() function to realize automatic compare function.

You can getting start with KSDK and KDS from reading below:

 "How to start with KSDK"  and "KDS Document List".

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
---------------------------------------------------------------------------------------------------------------------

0 Kudos

783 Views
yasararafathcs
Contributor II

Hi Shen,

Thank you for the clarification.

Actually I want interrupt with ranges. So I mentioned "But that gives interrupt when even 1 ADC sample also changed." Now I got the clarity.

I downloaded the SDK. I will try with that and get back to you.

Thanks & Regards,

Yasar Arafath

0 Kudos

783 Views
mjbcswitzerland
Specialist V

Hi

Please check chapter 2 of the following document: http://www.utasker.com/docs/uTasker/uTaskerADC.pdf
Is 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.

Regards

Mark
KL16 - http://www.utasker.com/kinetis/FRDM-KL27Z.html / http://www.utasker.com/kinetis/Capuccino-KL27.html

0 Kudos

783 Views
yasararafathcs
Contributor II

Hi Mark,

Thanks for the information.

I am checking the same. Also I have another doubt like from that document how to get interrupt only for ADC0_SE0?

Thanks & Regards,

Yasar Arafath

0 Kudos