AnsweredAssumed Answered

FTM to generate PWM in Output compare mode in KEA128

Question asked by VIGNESH BALAJI on Jan 24, 2019
Latest reply on Jan 24, 2019 by VIGNESH BALAJI

Hi,

     I want to generate PWM in FTM 2 Channel 1 pin PTH1 using output compare mode. Please help me in setting the duty cycle, frequency etc.

 

I have made the code snippet below which generates a PWM from the pin but don't know how to control it.

 

    SIM_SCGC |= SIM_SCGC_FTM2_MASK; /* Enable Clock for FTM2 */
    FTM2_SC |= FTM_SC_PS(7);    /* Select Preescaler in this case 128. 20 Mhz /128 =156.25 Khz. */
                                /* Counter increase by one every 6.4 us */
    FTM2_SC |= FTM_SC_CLKS(1); /*FTM2 use system clock*/
    SIM_PINSEL1 |= 0x0004;
    FTM2_C1SC = 0x14;

Outcomes