cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger input capture

Banana123
Associate II

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.

6 REPLIES 6
Sarra.S
ST Employee

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 )

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

- 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

Banana123
Associate II

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.

waclawekjan_0-1715949734678.png

 

Sarra.S
ST Employee

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 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Banana123
Associate II

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?