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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,763 次查看
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 项奖励
回复
1 解答
1,751 次查看
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

在原帖中查看解决方案

2 回复数
1,730 次查看
riglesias
Contributor II

Thanks for the reply

0 项奖励
回复
1,752 次查看
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