cancel
Showing results for 
Search instead for 
Did you mean: 

read access to the input GPIO pin in alternate function ?

eBirdman
Senior

Hello,

I need a clarification whether it is possible to read any pin status in alternate function just as it were a normal GPIO input pin. Is it so?

For ex. I configured the alternate function for a pin as a Timer Channel Input Capture pin, yet I can still access it to read as HAL_GPIO_ReadPin() ?

And also : if pin direct reading is possible, is it the same with all the alternate functions, or with some of them?

Thanks in advance for any help,

Vlad

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Yes, GPIOx_IDR is valid when the pin is in any AF mode. The Schmitt trigger, which feeds IDR, is only disconnected when the pin is in analog mode.

https://www.st.com/resource/en/application_note/an4899-stm32-microcontroller-gpio-configuration-for-hardware-settings-and-lowpower-consumption-stmicroelectronics.pdf

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

3 REPLIES 3
TDK
Guru

Yes, GPIOx_IDR is valid when the pin is in any AF mode. The Schmitt trigger, which feeds IDR, is only disconnected when the pin is in analog mode.

https://www.st.com/resource/en/application_note/an4899-stm32-microcontroller-gpio-configuration-for-hardware-settings-and-lowpower-consumption-stmicroelectronics.pdf

If you feel a post has answered your question, please click "Accept as Solution".

Thank you very much, provided link is of value too...

Ch.4.3.3 dedicated to the alternate functions indeed confirms that

"A read access to the input data register provides the I/O state"

Yet page 7 introduces a contradiction though, it says:

"• Input data to input data register (GPIOx_IDR) or peripheral (alternate function input)"

It says GPIOx_IDR OR peripheral , implying it is one or another...

Just a confusing wording?

I think you’re being too pedantic by reading into a simplified one-liner in the “features�? section when the detailed explanation section of the manual is so specific.
The word “or�? is ambiguous and can certainly mean both, as it does here.
You can also look in the reference manual at the GPIO pin structure figure to see that IDR is always connected except in analog mode.
If you feel a post has answered your question, please click "Accept as Solution".