Hi, I am trying to generate PWM in PTD1 pin using the FTM0 CH3.
But I am unable to get any output. But when I am configuring the PTD1 to FTM2 CH1(Alternative 4), I am able to get PWM output. Please find the configuration settings below for FTM0 CH3.
void FTM0_PWM_MODE()
{
PCC->PCCn[PCC_FLEXTMR0_INDEX] = PCC_PCCn_PCS(6) | PCC_PCCn_CGC_MASK; /* Enable clock for FTM2 */
PCC->PCCn[PCC_PORTD_INDEX] = PCC_PCCn_CGC_MASK; /* Enable clock for PORTD */
PORTD->PCR[1] = PORT_PCR_MUX(2); // Set PTD1 for FTM1 – Channel1
FTM0->MODE = 0x07; / /FTM_MODE_FTMEN_MASK;
FTM0->SYNCONF = 0x00000280;
FTM0->CONTROLS[3].CnSC=FTM_CnSC_MSB_MASK|FTM_CnSC_ELSB_MASK; // Select high-true pulses
FTM0->COMBINE =0x00000020;
FTM0->CNTIN = FTM_CNTIN_INIT(0);
FTM0->SC = 0x00FF000C;
FTM0->MOD = 50000 - 1;
FTM0->CONTROLS[3].CnV=FTM_CnV_VAL(25000);
}
FTM Counter frequency is 80Mhz/16(presacale). Could you please check and tell me why I am not able to use FTM0 CH3 for PTD1.
Hi,
if you update MOD/CnV after CLKS[1:0] ≠ 0:0 and FTMEN = 1 then trigger must be done (SW trigger in your case). It is not seen in your code, but probably you have it.
Also SYNCEN1 must be set to allow synchronization of pairs 2/3. But you have set SYNCEN0 only. Try to use
FTM0->COMBINE =0x00002000;
BR, Petr