STM32F103 GPIO config for alternate function input capture TIM1
Hi all,
I'm a newbie to STM32 and have been struggling with input capture for advanced timer TIM1 on the STM32F103.
Documentation shows that GPIO A8 can be used as an input for the timer input capture. This is one of the alternate functions for this pin.
I've followed the instructions given in the reference manual for the configuration of the timer for input capture. However, it did not work as the value of the capture/compare register was always 0.
After a lot of trial-and-error and searching I found that the problem was not so much with the configuration of the timer, but rather with the configuration of the GPIO pin. I had assumed that as I was using A8 as an input it had to be configured as an input (floating). Now the thing is that alternate functions are only selectable for outputs. When I configured A8 as an alternate function output (I chose open drain to play as safe as possible), the input capture started working and I got sensible values from the capture register.
It feels akward and confusing to configure a pin as alternate function output, while I'm actually using it as an input. I'm also a bit worried for hardware conflicts while driving this pin from an external peripheral.
So I have a few questions on this issue:
Is this really the way to configure this IO pin for input capture on the timer?
Is the output driver stage in this configuration disconnected from the pin?
Is this way of configuring an alternate function as output to get it to work as input only associated with the timer? I've used UART_RX before as an alternate function input and there the GPIO configuration was input mode (floating), worked fine....
I hope someone can shed some light on this subject as it confuses me quit a bit!
Thanks,
Filip
