AnsweredAssumed Answered

Trouble with a simple FTM counter

Question asked by Noah Guengerich on May 11, 2018
Latest reply on May 11, 2018 by Mark Butcher

Hi everyone, I was hoping you could tell me where I'm going wrong. I'm trying to set up a simple counter using the FTM in a MK64FX512VLQ12. I'm using the KSDK 2.3.0. Here's the code of interest:

 

void vConfigureTimer( void )

{

CLOCK_EnableClock(kCLOCK_Ftm0);

 

ftm_config_t ftmInfo = {

.prescale = kFTM_Prescale_Divide_16,

.bdmMode = kFTM_BdmMode_3,

.pwmSyncMode = kFTM_SoftwareTrigger,

.reloadPoints = 0,

.faultMode = kFTM_Fault_Disable,

.faultFilterValue = 0,

.deadTimePrescale = kFTM_Deadtime_Prescale_1,

.deadTimeValue = 0,

.extTriggers = 0,

.chnlInitState = 0,

.chnlPolarity = 0,

.useGlobalTimeBase = false

};

 

FTM_Init(FTM0, &ftmInfo);

FTM_StartTimer(FTM0, kFTM_FixedClock);

 

}

 

My understanding was that if the BDM mode was set to 3, the timer would run even during debugging. However, if I set up a simple routine to retrieve the counter value:

 

 

void PrintTimer( void )

{

   uint32_t timer = FTM0->CNT;

 

    PRINTF("%i\n", timer);

}

 

 

It just prints 0. Does anyone see where I'm going wrong? Thanks in advance for your help!

Outcomes