2022-01-16 10:26 AM
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).
Is this feasible?
2022-01-16 01:22 PM
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
2022-01-17 05:08 AM
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.
-SS