Skip to main content
Graduate
May 15, 2024
Question

How to trigger input capture

  • May 15, 2024
  • 6 replies
  • 2775 views

Hello All,

I want to trigger an input capture when another timer overflows. I have both timers set up, but I am missing on how to make the overflow event trigger the input capture of the other timer. The reference manual has been a good help, but I can't figure out how to connect the two timers.

    This topic has been closed for replies.

    6 replies

    ST Employee
    May 15, 2024

    Hello @Banana123

    Set up the master timer to generate an update event (UEV) on overflow. This is typically done by enabling the counter and allowing it to run until it overflows, which generates an update event. 

    For the slave timer, select the appropriate trigger input source (e.g., ITR0 if the master timer is TIM1, check TIMx internal connection tables in RM )

     

    Super User
    May 16, 2024

    - in master timer, select 0b010 for Update as TRGO source in TIMx_CR2.MMS

    - in slave timer, select the appropriate trigger source in TIMx_SMCR.TS as @Sarra.S said above

    - in slave timer, in TIMx_CCMRx.CCxS for the channel you want to capture on, select 0b11 for "mapped on TRC"

    JW

    Banana123Author
    Graduate
    May 17, 2024

    It is working, thank you very much!

    What is the purpose of the TRC bits? From the manual, I got that the bits do different things in different setups, but I couldn't find why this is necessary here or what TRC even stands for.

    Super User
    May 17, 2024

    waclawekjan_0-1715949734678.png

     

    ST Employee
    May 17, 2024

    I'm not exactly sure, but I would say TRC typically stands for trigger control.

    Mapping to TRC is necessary when you want the timer to react to an internal trigger signal rather than a simple external input or clock signal, which is typically other timers within the microcontroller 

    Banana123Author
    Graduate
    May 22, 2024

    Is triggering the input capture from another timer incompatible with external clock mode 1? I was hoping to increase the upper frequency limit of the captured channel, since external clock mode 2 is limited at 1/4 TIMxCLK. But I see that ECM1 needs TIMx_SMCR.TS set differently.

    Using a prescaler with ECM2 increases the frequency limit, but this causes other issues.

    Can a HRTimer counter be read out and clocked externally?