AnsweredAssumed Answered

FTM timing interrupt - Period No Change

Question asked by Leo Lu on Aug 13, 2018

How to simply get a predicable timing interrupt by using FTM?

But no matter how I adjusted the C0V value, the period what I could get was ~10us.

 

Could you please help check the following classic code and advice what else to change?

 

    /* Enable Clock for FTM1 */
    SIM_SCGC |= SIM_SCGC_FTM1_MASK;
    /* Select Timer Prescale equal to 128, 16MHz/128 = 125kHz */
    FTM1_SC |= FTM_SC_PS(7);   
    /* Enable Channel 0 */
    /* Enable channel 0 interrupt */
    FTM1_C0SC |= FTM_CnSC_CHIE_MASK;
    /* Channel as Output compare mode */
    FTM1_C0SC |= FTM_CnSC_MSA_MASK;
    /* Interrupt every 8us * 30 = 240us ? */
   FTM1_C0V = FTM_CnV_VAL(30);
    /* FTM1 use system clock */
    FTM1_SC |= FTM_SC_CLKS(1);

    /* Set the ICPR and ISER registers accordingly */
    NVIC_ICPR |= 1 << ((INT_FTM1-16)%32);
    NVIC_ISER |= 1 << ((INT_FTM1-16)%32);

Outcomes