Combine mode

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Combine mode

1,024 次查看
mickholmark
Contributor I

Hi

I am sitting and using the FTM for capture mode on rising

edge. I am trying to detect a frequenzy between two rising

edge.

Its working also good when i make a preescale at 16 but i

wont to work with out a preescale and using 32 bit. I know i

can combine to channelse FTM0_C0V and FTM0_C1V in pwm

mode but have to do it in capture mode?

i but my code under so you can see

void ftm_init()

{

        //Enable clock

        POWER_UP(6, SIM_SCGC6_FTM0);

    

        PORTC_PCR1 |= PORT_MUX_ALT4;//s. 266

        PORTC_PCR2 |= PORT_MUX_ALT4;//s. 266

        

        //FTM0_COMBINE = 0x32;

        FTM0_COMBINE = 0xFFFF;

        

        FTM0_CNT = 0x0000;

        // modulo to max

        FTM0_MOD = 0xffff;

        

    

        

        FTM0_C0SC &= ~FTM_CSC_CHF;    

        FTM0_C0SC |= FTM_CSC_CHIE;

        FTM0_C0SC &= ~FTM_CSC_MSB;

        FTM0_C0SC &= ~FTM_CSC_MSA;

        FTM0_C0SC &= ~FTM_CSC_ELSB;

        FTM0_C0SC |= FTM_CSC_ELSA;

        

        

        FTM0_C1SC &= ~FTM_CSC_CHF;    

        FTM0_C1SC |= FTM_CSC_CHIE;

        FTM0_C1SC &= ~FTM_CSC_MSB;

        FTM0_C1SC &= ~FTM_CSC_MSA;

        FTM0_C1SC &= ~FTM_CSC_ELSB;

        FTM0_C1SC |= FTM_CSC_ELSA;

        

        FTM0_MODE |= FTM_MODE_FTMEN;

        FTM0_SC |= FTM_SC_CLKS_SYS ;

        FTM0_SC |= FTM_SC_PS_1;

        if(isrControl == 0)

        fnEnterInterrupt(irq_FTM0_ID,

PRIORITY_HW_TIMER , ftm0_isr_nyt);

        

}

are you having any idee.

Iam working on a TWR-K60F120M

标签 (1)
标记 (2)
0 项奖励
回复
1 回复

757 次查看
egoodii
Senior Contributor III

I think you will find the details you need for pulse/period-width-measure in section '40.4.24 Dual Edge Capture mode' of K60P144M100SF2V2RM.pdf.  I think your 'COMBINE' register contents should contain just a couple bits for the capture-pair in question, such as just FTM_COMBINE_DECAPEN0_MASK, followed later by adding FTM_COMBINE_DECAP0_MASK. 

You might also get some benefit looking at the code I attached in https://community.freescale.com/thread/304806 for using dual-cap to catch an encoder index pulse, although in that case of course I am looking for opposite edges of one pulse.

You don't say 'how fast' you are trying to measure.  The FTM counter clock-rate may be limited to one-half the bus clock, I'm not sure on that!