AnsweredAssumed Answered

TPM with RTC Seconds as trigger

Question asked by Anders Esbensen on May 25, 2016
Latest reply on May 25, 2016 by xiangjun.rong


I am trying to the use the TPM as capture timer with RTC seconds as trigger on the K65

I have the TPM counter running and the RTC generates 1 second interrupts.

TPM input clock is OSCER.

TPM trigger is set to RTC Seconds (13) but i do not get any TPM channel interrupt.

However I do get TPM overflow interrupts which indicates that the TPM counter is running. Also I can see the count value changing.


My setup code look like this



        // Start Capture timer

        tpm_config_t config;


        config.prescale = kTPM_Prescale_Divide_1;

        config.useGlobalTimeBase = false;          /* Use internal TPM counter as timebase */

        config.enableDoze = false;                 /* TPM counter continues in doze mode */

        config.enableDebugMode = false;            /* TPM counter pauses when in debug mode */

        config.enableReloadOnTrigger = false;      /* TPM counter will not be reloaded on input trigger */

        config.enableStopOnOverflow = false;       /* TPM counter continues running after overflow */

        config.enableStartOnTrigger = false;        /* TPM counter starts on first trigger */

        config.enablePauseOnTrigger = false;       /* TPM does not pause on trigger */

        config.triggerSelect = kTPM_Trigger_Select_13;        /* Choose trigger select 0 as input trigger for controlling counter operation */

        config.triggerSource = kTPM_TriggerSource_External;   /* Choose external trigger source to control counter operation */



        TPM_Init(TPM1, &config);

        // Enable overflow interrupt

        TPM_EnableInterrupts(TPM1, kTPM_Chnl0InterruptEnable | kTPM_TimeOverflowInterruptEnable);





        TPM1->CNT = 0x0;

        TPM1->MOD = 0xFFFF;

        // Clear overflow flag

        TPM1->SC |= TPM_SC_TOF_MASK;



        TPM_SetupInputCapture(TPM1,kTPM_Chnl_0, kTPM_RisingEdge);

        TPM_StartTimer(TPM1, kTPM_SystemClock);



Have anyone of you tried this configuration with success.


Any suggestions appreciated.


Best regards