2011-10-26 11:27 AM
In the STM32 reference manual (
Doc ID 13902 Rev 13
) in section 9.1.4 it states:It is also possible to emulate the AFI input pin by software by programming the GPIO controller. In this case, the port should be configured in Alternate Function Output mode. And obviously, the corresponding port should not be driven externally as it will be driven by the software using the GPIO controller.
The question is how to use this? I'd like to simulate encoder inputs to TIM4. But if I set the GPIO B6 (TIM4 CH1) and B7 (TIM4 CH2) pins to alternale output it disconnects the ODR output register, so how can I set/reset the B6 and B7 pins in software? CPU is an STM32F103Z on a STM3210E eval board.
Jack Peacock #gpio-alternate-function2011-10-26 12:59 PM
According to the pin diagram, I think you'll find you need to program the pin as a ''GPIO Output Push-Pull'', and the AF Input will then read the state you are driving via normal GPIO settings.
GPIO vs AF Output is selected via a mux, so setting it as AF Output appears to be nonsensical.2012-09-03 12:52 AM
Just for those who read this and are wondering:
Setting the pin to Output Push-Pull, as clive1 suggested, is indeed correct.