I want to use FTM0 on the K70 to generate a 60Hz pulse. My code is in the attachment. The issue is nothing comes out on the PTD6 pin. I've checked the register values using a debugger and they all show correct except FTM0_C6V and C7V which show all zeros. Any ideas as to what is wrong?
Original Attachment has been moved to: FTM-Handler.c.txt.zip
Hi Keen,
I little bit try some settings on FTM in COMBINE mode. The following setting is functional. I used your settings and little modification. Very important is using pwmload after any of changing of value regiter and also use software trigger.
// Disable clock, prescaler = /128; up counter
FTM0_SC = FTM_SC_PS(7);
FTM0_MODE = (FTM_MODE_FTMEN_MASK); //enable all regs
FTM0_QDCTRL &= ~FTM_QDCTRL_QUADEN_MASK;
FTM0_C6SC = 8; //ELSB = 1, ELSA = 0
FTM0_CNTIN = 0; //initial counter value
FTM0_COMBINE &= ~FTM_COMBINE_DECAPEN0_MASK;
FTM0_COMBINE = FTM_COMBINE_COMBINE3_MASK; //combine ch 6 & 7
FTM0_OUTINIT = 0; //initial output = low
FTM0_MOD = FTM_MOD_VALUE; //final count
FTM0_C6V = channel_val0; //count at which output goes high
FTM0_PWMLOAD |= FTM_PWMLOAD_CH6SEL_MASK;
FTM0_C7V = channel_val1; //count at which output goes low
FTM0_PWMLOAD |= FTM_PWMLOAD_CH7SEL_MASK;
FTM0_SC |= FTM_SC_CLKS(1); //enable by selecting sys clk
FTM0_SYNC |= FTM_SYNC_SWSYNC_MASK;
I hope, this help,
regards,
Pavel