FTM not working unless COMBINE=1 on MK20DX128

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FTM not working unless COMBINE=1 on MK20DX128

458 Views
stefanburstrom
Contributor I

I am trying to generate 6 independent edge aligned PWM signals (with the same time base) using a MK20DX128 and I cannot get the PWMs to run. All examples that I have found are setting COMBINE=1 for the channels which gives me 4 combined channels, but I need to use them individually and I dont need the inverted version of the signal. If I clear FTM_ENABLE in FTM_MODE, then I get the channels running, but as soon as FTM_ENABLE is 1, then the channels are silent if I dont configure them to be combined.

According to the docs, it should be possible to run the channels with COMBINE=0, but I am not sure what I am missing when I set up the channels. What is the purpose of FTM_ENABLE?

This is how I configure the FTM:

FTM0_MODE = FTM_MODE_FTMEN_MASK | FTM_MODE_WPDIS_MASK;

FTM0_SC = FTM_SC_PS(1) | FTM_SC_CLKS(1);

FTM_CnSC_REG(FTM0_BASE_PTR,channel) = FTM_CnSC_MSB_MASK | FTM_CnSC_ELSA_MASK;

FTM0_MOD = period;

FTM_CnV_REG(FTM0_BASE_PTR,channel) = low_time;

FTM0_PWMLOAD = FTM_PWMLOAD_LDOK_MASK | 0xff;

What am I missing? Or should I simply run the FTM with FTM_ENABLE = 0 (this seems odd to me, but FTM_ENABLE is not really documented so it is not clear what functionality that will be missed)

Thanks!

/Stefan

Tags (2)
0 Kudos
1 Reply

355 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

If you want to set up the FTM to output 6 PWM signals, you should clear the COMBINEx and COMPx bits, for example, if you want to output indepent PWM signals from FTM_CH0/FTM_CH1/FTM_CH2/FTM_CH3/FTM_CH4/FTM_CH5 pins, you have to clear the COMBINE0,COMBINE1,COMBINE2 and clear COMP0,COMP1,COMP2.

For you code, I suggest you put the code at the end of initialization, after you set the FTM0_SC = FTM_SC_PS(1) | FTM_SC_CLKS(1);, the FTM runs immediately.

Hope it can help you.

BR

Xiangjun Rong

0 Kudos