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

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

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

Jump to solution
1,992 Views
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,

Tags (1)
1 Solution
1,631 Views
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

View solution in original post

1 Reply
1,632 Views
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