Skip to main content
eBirdman
Senior
December 23, 2021
Solved

read access to the input GPIO pin in alternate function ?

  • December 23, 2021
  • 3 replies
  • 3580 views

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

    This topic has been closed for replies.
    Best answer by TDK

    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

    3 replies

    TDK
    TDKBest answer
    December 23, 2021

    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""."
    eBirdman
    eBirdmanAuthor
    Senior
    December 23, 2021

    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?

    TDK
    December 23, 2021
    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""."