AnsweredAssumed Answered

Period/frequency measurement using K02F family

Question asked by Snehal Patil on Feb 3, 2016
Latest reply on Feb 15, 2016 by xiangjun.rong

I want to measure frequency/period of square wave signal which may vary between 40-60Hz. I am trying to use dual capture mode.I have written below initialization code but I am getting confused with following queries:

ftm_init()

{

 

 

 

ftm_dual_edge_capture_param_t param;

 

ftm_user_config_t user_info;

 

user_info.tofFrequency=0; 

 

user_info.BDMMode= kFtmBdmMode_11;

 

 

 

 

 

user_info.isWriteProtection=false;

 

 

user_info.syncMethod=kFtmUseSoftwareTrig;

 

 

FTM_DRV_Init(BOARD_FTM_INSTANCE, &user_info);

 

 

FTM_DRV_SetClock(BOARD_FTM_INSTANCE,kClock_source_FTM_SystemClk, kFtmDividedBy1);

 

param.mode=kFtmContinuous;

 

 

 

param.currChanEdgeMode=kFtmRisingEdge;

 

 

param.nextChanEdgeMode=kFtmRisingEdge;

 

 

FTM_DRV_SetupChnDualEdgeCapture (BOARD_FTM_INSTANCE, &param,BOARD_FTM_X_CHANNEL,0);

 

 

 

 

}

 

Doubts:

1. Is this initialization function correct?

2. How to read status of CHnF and CH(n+1)F to read the channel/counter value. As there is no any function for it in driver. If directly through register address then in which file I could find it. In MK02F12810.h file I find macro

 

FTM_STATUS_CH0F(x)  what is x in this... is this bit position?

3. Through function I can read C(n)V and C(n+1)V registers.

4. Is there any reference code for period measurement ?

5. Is my initialization for structure ftm_user_config_t correct?

 

Note: BOARD_FTM_INSTANCE = 0

         BOARD_FTM_X_CHANNEL = 0

 

 

 

Snehal.

Outcomes