cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Gated Timer with TIM2_CH3

SS13
Associate II

I want to count the 'high time' of a signal on TIM2_CH3. I simply want to count up TIM2 by using internal clock, but gating it with TIM2_CH3. I don't care about interrupts; I only want to use the counter value to access how much 'activity' has occurred since last time I read the counter (which is the difference in the previous and current values).

0693W00000JM8mcQAD.pngIs this feasible?

2 REPLIES 2

Yes.

"Oficially", you'd need to assign a pin to TIM2_CH1 and TIM2_CH2 each, and set both to low (e.g. by setting a pulldown for them). However, if you are OK with an undocumented feature, simply just don't assign any pin to TIM2_CH1 nor TIM2_CH2 in GPIO.

JW

SS13
Associate II

Thanks for the response. Now I understand that, when using the XOR gate, all three signals must be used as inputs. Rather than using this I may prefer to use TIM9. Unfortunately, the counter is 16-bit, but if an appropriate prescaler are chosen, I think this will be acceptable.

0693W00000JMEC1QAP.png0693W00000JMECfQAP.png-SS