Skip to main content
mahdi zamani
Associate III
November 20, 2016
Question

stm32 timer captur

  • November 20, 2016
  • 2 replies
  • 673 views
Posted on November 20, 2016 at 07:58

hey all

i configed timer 3 whit this ....

formeasurement frecuncy in PA.7

void TIM3_Configuration(void){

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);

TIM_ICInitTypeDef TIM_ICInitStructure;

TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;

TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;

TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;

TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;

TIM_ICInitStructure.TIM_ICFilter = 0x0;

TIM_ICInit(TIM3, &TIM_ICInitStructure);

/* TIM enable counter */

TIM_Cmd(TIM3, ENABLE);

/* Enable the CC2 Interrupt Request */

TIM_ITConfig(TIM3, TIM_IT_CC2, ENABLE);

NVIC_InitTypeDef NVIC_InitStructure;

/* Enable the TIM3 global Interrupt */

NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

}

i read captur whit this code :

frq=TIM_GetCapture2(TIM3); but not work :(((

please help to me ...

thanks

    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    November 20, 2016
    Posted on November 20, 2016 at 08:37

    Ok, so what are you seeing when you read the capture register, and what were you expecting to see?

    Tends to be a time stamp of the time base, which advances, so you'd need to delta it.

    Which STM32, they make a few versions these days.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    mahdi zamani
    Associate III
    November 20, 2016
    Posted on November 20, 2016 at 08:55

    void TIM3_Configuration(void){

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);

    TIM_ICInitTypeDef TIM_ICInitStructure;

    TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;

    TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;

    TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;

    TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;

    TIM_ICInitStructure.TIM_ICFilter = 0x0;

    TIM_ICInit(TIM3, &TIM_ICInitStructure);

    /* TIM enable counter */

    TIM_Cmd(TIM3, ENABLE);

    /* Enable the CC2 Interrupt Request */

    TIM_ITConfig(TIM3, TIM_IT_CC2, ENABLE);

    NVIC_InitTypeDef NVIC_InitStructure;

    /* Enable the TIM3 global Interrupt */

    NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;

    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    NVIC_Init(&NVIC_InitStructure);

    }

    void assert_failed(uint8_t* file, uint32_t line)

    {

    /* User can add his own implementation to report the file name and line number,

    ex: printf(''Wrong parameters value: file %s on line %d\r\n'', file, line) */

    while (1)

    {}

    }    complete programme can edite my program tomeasurement frequncy at PA.6 and write it to ''FRQQ''?  i downloaded sample for this but i cant work on it :( sorry itsthe first my project whit stm32 ... thanks