AnsweredAssumed Answered

FTM0 Quadrature decoder

Question asked by David Cantero on Nov 24, 2014
Latest reply on Dec 2, 2014 by EARL GOODRICH

Hi everybody!!

 

I´m involved in a proyect with kinetis K60f120 to control 3 DC motors with encoder. I have used the FTM3 to generate PWM signals and the other 3 FTM modules (FTM0, FTM1 and FTM2) to connect the motor encoders. I have used the same code to initialize all FTM modules, but two of them work properly (FTM1 and FTM2) but the third (FTM0) dont work.

FTM0 is more general FTM module than the others, so could be necesary something else for correct initialization???

 

This is the code I have used:

 

// enable the clock for FTM1

  SIM_SCGC6 |= SIM_SCGC6_FTM0_MASK;

 

  //enable the counter

  FTM0_MODE |= FTM_MODE_FTMEN_MASK;

  

  FTM0_CONF |= FTM_CONF_BDMMODE(3); // counter running in BDM mode

 

  FTM0_MOD = 3999;

  FTM0_CNTIN = 0;

  FTM0_CNT = 0;

  FTM0_QDCTRL |= FTM_QDCTRL_QUADEN_MASK | FTM_QDCTRL_QUADMODE_MASK; // configuring for quadrature mode

  // start the timer clock, source is the external clock

  FTM0_SC |= FTM_SC_CLKS(3);

 

  //configuring the input pins:

  PORTC_PCR1 = PORT_PCR_MUX(4); // FTM0 CH0

  PORTC_PCR2 = PORT_PCR_MUX(4); // FTM0 CH1

 

 

Any suggestion??????

 

Thanks in advance!!!!!!

 

David.

Outcomes