AnsweredAssumed Answered

FRDM KL26 TPM (Input Capture Mode)

Question asked by Alex Leonte on Sep 18, 2015
Latest reply on Sep 21, 2015 by Alex Leonte

Hello,

 

I have an FRDM-KL26 MCU and I'm writing a TPM/PWM driver, but can't accomplish it, so I have a couple of questions:

 

1.TPM0 has 5 channels.It is possible to use all of these channels as input capture ?

 

2.I already configured one channel for input capture mode, but i can`t clear TOF(timer overflow flag) register in ISR. ( it is because another overflow occurred before i cleared first time ?)

 

 

 

Example of ISR:

 

void Io_Tpm_Tpm1Isr(void)

{

 

    if(TPM_STATUS_REG(TPM1) & TPM_STATUS_TOF_MASK){                                            /* check if TOF is set */

        TPM1_SC |= TPM_SC_TOF_MASK;    /* Delete the TOF flag such that the IRQ ends */

    }

 

    if( TPM_STATUS_REG(TPM1) & TPM_STATUS_CH0F_MASK ){                                        /* CHANNEL 0*/

        TPM_CnSC_REG(TPM1,IO_TPM_CHANNEL0) |=  TPM_CnSC_CHF_MASK;                            /*Clear CHF  - event occurred */

 

    }else if(TPM_STATUS_REG(TPM1) & TPM_STATUS_CH1F_MASK){                                    /* CHANNEL 1*/

        TPM_CnSC_REG(TPM1,IO_TPM_CHANNEL1) |=  TPM_CnSC_CHF_MASK;                            /*Clear CHF  - event occurred */

    }

 

}

Outcomes