AnsweredAssumed Answered

Accurate waveform of FTM

Question asked by Kiyoshi Matsuzaki on Feb 3, 2016
Latest reply on Feb 4, 2016 by xiangjun.rong

Hi, everyone

 

I made custom boards with K64.

I connected stepper motors to FTM0, 1 ,2.

I use FTM driver in Kinetis Platform Library.

I set 500Hz to 10000Hz to each FTM.

 

I need accurate waveform from FTMs.

I checked the waveform by my Oscilloscope, and waveform was not accurate.

 

For example, I measured pulses of waveform during a second.

I set 10000Hz to FTM > I got 9948 pulses.

I set 3500Hz to FTM > I got 3500 pulses. It was OK.

I set 2000Hz to FTM > I got 4021 pulses.

 

These are not enough for me.

How can I get more accurate waveform?

 

 

Some parts of my test code are below.

(FTM0,1,2 use same parameters)

 

-----------------------------------------------------------------------------------------------------------

 

// parameters

ftm_pwm_param_t ftm0param =

{

    .mode                   = kFtmEdgeAlignedPWM,

    .edgeMode               = kFtmLowTrue,

    .uFrequencyHZ           = 10000,

    .uDutyCyclePercent      = 50,

    .uFirstEdgeDelayPercent = 0,

};

 

// Clock setting

g_xtal0ClkFreq = 50000000U;

g_xtalRtcClkFreq = 32768U;

BOARD_ClockInit();

 

// FTM setting

FTM_DRV_SetClock(FTM0, kClock_source_FTM_SystemClk, kFtmDividedBy128);

FTM_DRV_SetClock(FTM1, kClock_source_FTM_SystemClk, kFtmDividedBy128);

FTM_DRV_SetClock(FTM2, kClock_source_FTM_SystemClk, kFtmDividedBy128);

 

// Clock start

FTM_DRV_PwmStart(FTM0, &ftm0param, CH0);

FTM_DRV_SetTimeOverflowIntCmd(FTM0, 1);

 

-----------------------------------------------------------------------------------------------------------

 

If somebody have information, please let me know.

 

Regards,

 

Kiyoshi Matsuzaki

Outcomes