K22 FTM Quadrature Decoder

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

K22 FTM Quadrature Decoder

1,655 Views
kent_gu
Contributor III

Hi,

Now I use MK22FN1M0AVLH12 64pin chip, on page 997 of K22 Sub-Family Reference Manual, Rev. 5, March 15, it mentioned that FTM Quadrature Decoder, but I can't find the which pin of MK22FN1M0AVLH12 connect to Phase A, Phase B. If possible, could you please show me Phase A and Phase B pins number and demo SW?

Thanks in advance!

Best Regards,

Kent

0 Kudos
8 Replies

1,132 Views
kent_gu
Contributor III

XiaoJun,

Thanks a lot for your reply, also thanks a lot for your Freemaster tool recommendation.

But I want to use "FTM2 Quadrature Decoder" to sample FTM2_QD_PHA and FTM2_QD_PHB signals, and read the FTM counter, it is for motor speed detection.

Any KSDK2.0 example for "Quadrature decoder mode" using FTM?

Best regards,

Kent

0 Kudos

1,132 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I do not think that the SDK2.0 has example for quadrature module, but I think SDK2.0 provides the corresponding api function.

BR

Xiangjun Rong

0 Kudos

1,132 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Kent,

As the other engineers said that the K22 has three FTM modules FTM0/FTM1/FTM2, the FTM0 has 8 channles, and is used to generate PWM signhal to control motor, only the FTM1 and FTM has the decodering function. The FTM1 decoding pin are FTM1_QD_PHA/FTM1_QD_PHB, the FTM2 decodering pins are FTM2_QD_PHA/FTM2_QD_PHB, The RM has  the pin assiognment as Kiss said.

I suggest you refer to an5142, which has the code for decodering.

http://cache.nxp.com/files/32bit/doc/app_note/AN5142.pdf?fsrch=1&sr=1&pageNum=1 

Hope it can help you.

BR

Xiangjun Rong

0 Kudos

1,132 Views
kent_gu
Contributor III

Hi, Xiangjun,

Thank you a lot for your reply, it is helpful. Yes, I saw the demo code in the page 18 of an5142, there is quadratureDecoder intial and period interrupt. Now I want to pop up the counter value when encoder PHA & PHB happen, so I want to use the processor express to realize the code. But I don't know how to setting?FTM_QD.jpg

Could you please give me some advice?

 

The below site, which have some setting about it, but it lost some picture or infromation.

https://community.nxp.com/thread/350276

 

 

Best Regards,

Kent

0 Kudos

1,132 Views
kent_gu
Contributor III

Hi,

Anyone have any input about, "want to pop up the counter value when encoder PHA & PHB dual edge"? It means that at  the dual edge of PHA & PHB trigger interrupt, and enter ISR?

Best Regards,

Kent

0 Kudos

1,132 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Kent,

where do you want to pop up the FTM counter? I think you can use Freemaster tools to display the FTM counter, in the case, you can read the FTM counter to a variable in the main loop so that Freemaster tools can display the variable. As an alternative, you can use PIT to generate an interrupt, in the ISR of PIT, read FTM counter to a variable so that the Freemaster tools can display it.

If you use UART module to transfer the FTM counter, you can read the FTM counter in the ISR of UART.

Hope it can help you.

BR

Xiangjun Rong

0 Kudos

1,132 Views
egoodii
Senior Contributor III

As for demo, you might get some info with the code & comments I have posted here:

https://community.nxp.com/thread/304806 

0 Kudos

1,132 Views
renato_kiss
NXP Employee
NXP Employee

Hello Kent,

You can use either the Ref Manual or the Datasheet to check it. DS, you can try http://www.nxp.com/files/32bit/doc/ref_manual/K22P64M120SF5V2RM.pdf?fasp=1&WT_TYPE=Reference%20Manua... 

In RM, in Chapter 10.3, you can see a table for pin vs functions. For Quadrature, it depends on which FTM you intend to use. For example, for FTM1, pins 28 and 29 can be set for Quadrature function using the ALT7 (pin function alternative 7) or pins 35 and 36 using ALT6.

For selecting Pins you can use in the Kinetis Expert SW Website the Pins Tool - https://kex.nxp.com/en/pins. There you can check all the possibilities for Quadrature.

Regards,

Renato Kiss

0 Kudos