cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32L4R5] how to configure TIM2 channel3 as PWM input capture, TI3 orTI4 as trigger input

b.a.
Associate III

I want to capture several PWM signals, i.e. measure the pulse width

The reference manual gives an example for TIM2 TI1 that uses channel 1 and channel 2 to measure pulse width and period. Therefore SMCR.TS bits are set to use filtered TI1 as trigger/reset.
I want to do the same for TIM2 channel 3, but I don't see how I can set TI3 as trigger/reset source
Is it not possible to have the individual channels of TIM2 (or any timer) reset by different sources?

 

What I try to achieve is that a rising edge on TI1 starts CCR1 counting and have the value at a falling edge of TI1.
And I want the same for a rising edge on TI3, starting CCR3 counting and have the value at a falling edge of TI3.

 

How can I do this?

 

As far as I have seen SMCR allows only TI1 or TI2 as trigger source (or other timers, but that does not help here?)

1 REPLY 1

> Is it not possible to have the individual channels of TIM2 (or any timer) reset by different sources?

There is only one counter in TIM2, and only one source to reset it (chosen by TIMx_SMCR.TS); and in that you can't select TIMx_CH3  as the trigger source.

If the edges of input signal are not too close to each other (i.e. input frequency is relatively low and pulses not too long or short), you can set TIMx_CH3 to capture on both edges, and from the captured values calculate both period and duty.

JW