Skip to main content
Visitor II
April 10, 2006
Question

using STR710 timer1 to count external pulses

  • April 10, 2006
  • 3 replies
  • 999 views
Posted on April 10, 2006 at 09:39

using STR710 timer1 to count external pulses

    This topic has been closed for replies.

    3 replies

    aialinuxAuthor
    Visitor II
    April 7, 2006
    Posted on April 08, 2006 at 01:46

    I am using STR710 timer1 to count external pulses.

    When the timer1 Overflow,It can't jump to the IRQHandler.I don't know why!

    // try to make sure that timer1 is in ''normal'' mode

    // Initialize the Timer 1

    TIM_Init ( TIM1 );

    TIM_ClockSourceConfig ( TIM1, TIM_EXTERNAL );//TIM_EXTERNAL

    TIM_ClockLevelConfig ( TIM1, TIM_RISING ); // TIM_FALLING

    TIM_ITConfig(TIM1, TIM_TO_IT, ENABLE);

    GPIO_Config (GPIO1, 0x0010, GPIO_IN_TRI_CMOS);//pin 1.4,extclk

    [ This message was edited by: dom on 08-04-2006 10:57 ]

    Visitor II
    April 10, 2006
    Posted on April 10, 2006 at 06:15

    You need to add some statement:

    TIM_CounterConfig(TIM1,TIM_START); //Start counting

    TIM_FlagClear(TIM1, TIM_TOF); //Clear overflow flag

    TIM_ITConfig(TIM1,TIM_TOF,ENABLE); //enable this int (overflow).

    remove your line:

    TIM_ITConfig(TIM1, TIM_TO_IT, ENABLE);

    in your int, you need to call:

    TIM_FlagClear(TIM1, TIM_TOF); //Clear overflow flag.

    Chris.

    aialinuxAuthor
    Visitor II
    April 10, 2006
    Posted on April 10, 2006 at 09:39

    I found some strange! When I using TIM0 for periodic timer interrupt and TIM1 to count external pulses,It only respond the TIM0 periodic interrupt .

    TIM1 Overflow interrupt never respond.

    When I just using TIM1 to count external pulses,it can jump to the ISR.