Frequency and duty cycle calculation using dual edge capture

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

Frequency and duty cycle calculation using dual edge capture

1,303 Views
nitinverma
Contributor III

Dear Support Team,

 

We are using Freedom board for s32k144. We wanted to calculate the duty cycle and frequency of input captured signal using dual edge capture mode.We couldn't be able to calculate both the parameter simultaneously using dual edge capture mode with same channel configuration.We don't want to use another channel for frequency/period calculation.Please guide how to achieve it.

 

 

 

BR,

Nitin verma

0 Kudos
Reply
1 Reply

761 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Nitin,

I suppose you use capture function of FTM module to measure the duty cycle and cycle time of S32K.

I think it is okay to compute both the duty cycle and cycle time of tested signal connected to FTM even channel FTM_CH2n with dual edge capture mode.

If you set the FTM in dual capture mode and cointinuous mode, you can set the ELSnB:ELSnA bits to select the first edge of the captured signal, set ELSn+1B:ELSn+1A bits to select the second edge of the captured signal, the first edge triggers to copy the FTM_CNT to FTM_CnV register automatically, the second edge triggers to copy the FTM_CNT to FTM_CnV register automatically, meanwhile, the second edge can trigger an interrupt. If you use continuous mode, each second edge will trigger an interrupt. In the ISR  triggered by the second edge, you can read the FTM_CnV to for example FirstArray[], read the FTM_Cn+1V to for example secondArray[], after you get for example 100 ISR, you can disable the ISR.

duty cycle=secondArray[x]-FirstArray[x]; //x is any value

cycle time =FirstArray[x+1]-FirstArray[x]; or cycle time =secondArray[x+1]-secondArray[x];

Hope it can help you

BR

Xiangjun Rong

0 Kudos
Reply