Skip to main content
Siragh ASUTP
Associate II
May 1, 2017
Question

How to determine from which channel the capture took place?

  • May 1, 2017
  • 3 replies
  • 1040 views
Posted on May 01, 2017 at 08:06

Hello. I use stm32a4 and timer2 (channel 3 and channel 4) in capture mode. How to determine from which channel the capture took place?

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    May 1, 2017
    Posted on May 01, 2017 at 18:11

    Check the TIMx->SR it flags which channel(s) captured.

    Use the TIMx->SR = ~CLEARTHISBIT; // not the &= RMW form

    void TIM2_IRQHandler(void)

    {

    if(TIM_GetITStatus(TIM2, TIM_IT_CC3) == SET)

    {

    TIM_ClearITPendingBit(TIM2, TIM_IT_CC3);

    Cap3 = TIM_GetCapture3(TIM2);

    }

    if(TIM_GetITStatus(TIM2, TIM_IT_CC4) == SET)

    {

    TIM_ClearITPendingBit(TIM2, TIM_IT_CC4);

    Cap4 = TIM_GetCapture4(TIM2);

    }

    }

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    May 1, 2017
    Posted on May 01, 2017 at 18:12

    Duplicate Thread

    https://community.st.com/0D50X00009XkdeMSAR

     
    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Siragh ASUTP
    Associate II
    May 16, 2017
    Posted on May 16, 2017 at 06:22

    Thanks for the answer. I use the HAL library. Can you give an example for this library?

    Tesla DeLorean
    Guru
    May 16, 2017
    Posted on May 16, 2017 at 18:46

    No

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..