? How to create input-capture (TPM0) Handler in KL25Z

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

? How to create input-capture (TPM0) Handler in KL25Z

跳至解决方案
2,424 次查看
ofiryaish
Contributor II

HI,
 I'm new in programming KL25Z, and I'm trying to understand how I can handle an interrupt in input-capture mode of  TPM. I got build-in handles for a lot of ports and timers such as PORT A/D, timer PIT and I don't know who created them or how (I'm working on code that was given to me by university). unfortunately, there is not any handler for any TPM.
without having an handler for it, it seems to me useless to use  input-capture mode.

I'm adding the startup code with all the handlers I got. 
I will appreciate a solution for that,

标记 (1)
1 解答
2,063 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Ofir

From hardware perspective, you have to connect the external signal to TPM_CHx pin, all the TPM function share the same interrupt vector, so you have to check the interrupt source in the FTM0_IRQHandler(), which is the ISR of the FTM capture interrupt.

From software perspective, all TPM pins are multiplexed with the GPIO pins, this is the process:

1)enable PORT  clock in the SIM_SCGC5

2)set the MUX bits of  PORTx_PCRy so that the pin function as TPM.

3)configure the TPM module

4)enable interrupt for example

I attach an example for capture function based on KE02, pls refer to it.

Hope it can help you

BR

Xiangjun Rong

在原帖中查看解决方案

1 回复
2,064 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Ofir

From hardware perspective, you have to connect the external signal to TPM_CHx pin, all the TPM function share the same interrupt vector, so you have to check the interrupt source in the FTM0_IRQHandler(), which is the ISR of the FTM capture interrupt.

From software perspective, all TPM pins are multiplexed with the GPIO pins, this is the process:

1)enable PORT  clock in the SIM_SCGC5

2)set the MUX bits of  PORTx_PCRy so that the pin function as TPM.

3)configure the TPM module

4)enable interrupt for example

I attach an example for capture function based on KE02, pls refer to it.

Hope it can help you

BR

Xiangjun Rong