Skip to main content
Visitor II
March 15, 2004
Question

MFT on ST92F150CV

  • March 15, 2004
  • 2 replies
  • 677 views
Posted on March 15, 2004 at 06:09

MFT on ST92F150CV

    This topic has been closed for replies.

    2 replies

    siegmundAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 11:35

    Hi there!

    i've got a problem with the MFT0.

    i just want to measure the duration auf a signal, which comes about 50times a second.

    the MFT0 is programmed with:

    trigger on T0INA, Clear on Capture, IT for Capture enabled.

    DMA not enabled.

    But the Capture-IT will be called to often, while the Capture-Event occures rare.

    when the capture occures, the count-value is ok, when no signal is connected, the overflow-IT occures - this is all correct so far.

    but why is the capture-IT called so often, with no Flag (T_FLAGR & Tm_cp0) set?

    I don't know were the problem is.

    can anybody help me?

    thanks.

    siggi

    ----------------------- here is the listing: --------------------------- snip

    void INIT_MFT(void)

    {

    // Disable IT

    di();

    spp(T0D_PG);

    T_PRSR =2; // Value of the prescaler

    T_REG0R = 0x8000; // Initial value of the counter

    T_REG1R = 0x8000;

    T_TCR = Tm_ccp0 | Tm_udc; // Clear on Capture, Direction=Up

    T_TMR = Tm_rm0 | Tm_ren; // Capture on REG0R, Disable Retrigger

    T_ICR = Tm_exa_r | Tm_ab_ti; // TxINA=rising, Function=Trigger / IO

    T_OACR = bin(1,1,1,1,1,1,0,0); // Disable Outputs

    T_OBCR = bin(1,1,1,1,1,1,0,0);

    T_CMP0R = 0xf000; /* Initial value of Compare0 register */

    T_CMP1R = 0xf000; /* Initial value of Compare1 register */

    // Init II

    spp(T0C_PG);

    T0_IVR = 0x40; // IT vector

    T0_IDCR = 0; // Set priority

    spp(T0D_PG);

    T_IDMR = Tm_gtien | Tm_cp0i | Tm_oui; // Global IT mask for the MFT

    T_FLAGR = 0; // clear previous requests (=errors)

    ei();

    // Start MFT

    T_TCR |= Tm_cen;

    }

    #pragma INTERRUPT INT_MFT0_OVER 10

    void INT_MFT0_OVER(void) {

    debug2++;

    spp(T0D_PG);

    T_FLAGR &= ~Tm_ouf;

    };

    #pragma INTERRUPT INT_MFT0_CAPT 11

    void INT_MFT0_CAPT(void) {

    spp(T0D_PG);

    if ( (T_FLAGR & Tm_cp0)==Tm_cp0 ) {

    // Capture 0 occured

    debug3++;

    count[index]=T_REG0R;

    index++;

    if (index > 4) index=0;

    T_FLAGR &= ~Tm_cp0;

    } else {

    // Anything else occured !?

    debug4++;

    };

    };

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 11:35

    Hello There,

    You say you are using the MFT for measuring the duration of pulse so you are using the timer in triggered mode, but you also get an overflow interrupt without the trigger. whis is strange since in trigger mode the timer is running only when we have a trigger on the input PIN so check your configrations and try running it on Emulator.