Using CMP to compare 2 analog inputs + capturing a FTM counter value

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

Using CMP to compare 2 analog inputs + capturing a FTM counter value

Jump to solution
813 Views
riglesias
Contributor II

Hi, I want to configure the CMP to compare 2 analog inputs and capture a counter value depending on the comparator output, so i did the following:

1.On one hand, i know how to setup the CMP module and trigger an interrupt / put the result in CMP0_OUT.

2. On the other hand, i know how to set the FTM module (counter) in single edge capture mode to capture the counter value given a configured input.

And now, I want to mix these two things together and capture the FTM counter value when the CMP0_OUT is set.

I know that i can set FTM as a trigger source for CMP0_OUT, using TRGMUX like this:

TRGMUX->TRGMUXn[TRGMUX_FTM0_INDEX] = TRGMUX_TRGMUXn_SEL0(0x0E);
// 0x0E corresponds to CMP0_OUT
 
but i dont know if i need to do something more, or if this is the correct path to follow to do what i need to do, so im posting this question in case somebody can give any tips on how to to this in a proper way.
 
Thanks!!

 

0 Kudos
1 Solution
801 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,
If you want to capture the FTM CNT value on an active edge of the CMP0_OUT trigger signal, you can use SIM_FTMOPT1[FTM2CH0SEL, FTM1CH0SEL] to select CMP0_OUT instead of the FTM2_CH0 input, FTM1_CH0 input.
So, the CMP0_OUT signal will be the FTM IC input signal of the corresponding channel.
FTM0 does not support the feature though.

danielmartynek_0-1610100433345.png

Regards,

Daniel

View solution in original post

2 Replies
780 Views
riglesias
Contributor II

Thanks for the reply

0 Kudos
802 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,
If you want to capture the FTM CNT value on an active edge of the CMP0_OUT trigger signal, you can use SIM_FTMOPT1[FTM2CH0SEL, FTM1CH0SEL] to select CMP0_OUT instead of the FTM2_CH0 input, FTM1_CH0 input.
So, the CMP0_OUT signal will be the FTM IC input signal of the corresponding channel.
FTM0 does not support the feature though.

danielmartynek_0-1610100433345.png

Regards,

Daniel