Digital filter on the ADC KL02/03

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

Digital filter on the ADC KL02/03

1,018 Views
anderswesten
Contributor I

Hi, I need to make a simple digital filter on either KL02/03 (No DMA, and only 12Bit ADC), on the ADC. It must also be as low power as possible. Please any idea

/Anders

0 Kudos
4 Replies

497 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Pls refer to section 5.6 GDFLIB_FilterFIRInit, which tell you how to call the FIR api function and initialize the data structure. The DOC is based on M4, you can download the similar DOC for M0 from the website I gave you.

0 Kudos

497 Views
anderswesten
Contributor I

HI

Thank you for your answer, but I can see that I was not that clear in my question.

The input to the ADC is a sensor, and I would like to make a digital filter to make sure that noice etc. are not going to wake up the processor and starts to work.

I can see from your answer that the processor needs to wake up, and use the lib, that you sent me.

Is there a way of making some filter on the peripherel that don't wake up the processor?

Best regards

Anders

0 Kudos

497 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

It is unnecessary to care about that the noise signal on the ADC analog input channel can lead to processor waking up while the processor is in sleeping mode. If you do not select that the ADC is the waking-up source, the noise signal on ADC analog channel can not lead to waking up of the processor.

0 Kudos

497 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Anders,

Firstly, you should determine the sampling frequency, for example 1KHz,2KHz whatever which should be in the range of kl02 ADC converter, then in the normalized frequency from 0~2PI, you can design your FIR/IIR filter based on the digital filter type(IIR/FIR), pass-type(low/high/band pass) , then get the coefficients for example, I assume you design a FIR filter, you will get the coefficients h0, h1,h2,...,hn. you can save the coefficients in a static array, they are constants.

For the kl02 mcu, as you know, it has TPM, LPTMR0 timer, ADC module, and the hardware triggering circuits. If you want to implement the digital filter, the ADC conversion rate should be constant, we suggest customer use timer to trigger ADC so that the conversion rate is constant for each sample value from ADC converter.

based on the desired ADC sampling rate, you can set the TPM1 mod register,. set the TPM1 c0sc register as "output compare mode" and "Toggle output mode".

set the SIM_SOPT7 register, clear the  ADC0ALTTRGEN bit, the TPM1 channel0 will trigger ADC0 converter. all the description is based on KL02P20M48SF0RM doc.

configure the ADC0 module, set the ADCO bit in ADC0_SC3, set the ADTRG bit in ADC0_SC2, then set AIEN bit and the ADCH bits based on the exact channel you are using. I suppose you know how to set an interrupt for example enabling interrupt, setting the priority of interrupt source, changing interrupt vector.

write an ISR of ADC converter, in the ISR, read the sample from the ADC0_RA register, then calling FIR api function GDFLIB_FilterFIR(), it is okay.

we have developed the digital filter library for Cortex-M0 core, you can download it from the website:

http://tinyurl.com/lvt4pxu

I attach a doc which tell you how to call digital filter api function which is from the lib.

0 Kudos