How do you correctly setup Timer9 (TIM9)on an STM32F405xx to count pulses on rising edge? Is there a special configuration for the pin to the timer outside of this short example?
Here's what I've done so far and also followed the BRIEF counter example from the reference manual copied here:
For example, to configure the upcounter to count in response to a rising edge on the TI2 input, use the following procedure:
Configure channel 2 to detect rising edges on the TI2 input by writing CC2S = ‘01’ in the TIMx_CCMR1 register.
Configure the input filter duration by writing the IC2F[3:0] bits in the TIMx_CCMR1 register (if no filter is needed, keep IC2F=’0000’).
- Select the rising edge polarity by writing CC2P=’0’ and CC2NP=’0’ in the TIMx_CCER register.
- Configure the timer in external clock mode 1 by writing SMS=’111’ in the TIMx_SMCR register.
- Select TI2 as the trigger input source by writing TS=’110’ in the TIMx_SMCR register.
- Enable the counter by writing CEN=’1’ in the TIMx_CR1 register.
I believe I've done the above correctly, but reading the register returns 0 always. Is there any additional setup within a different register to connect the to the Timer? I was reading about
alternate functions but could not find anything specific to Timers and Pins.
I am loosely following this as a code reference: https://www.ghielectronics.com/docs/108/register-access
Chip Family Reference Manual: http://www.st.com/web/en/resource/technical/document/reference_manual/DM00031020.pdf