Skip to main content
sprhawk
Associate II
November 5, 2015
Question

How to conveniently read GPIO while it is in AF mode ?

  • November 5, 2015
  • 4 replies
  • 1322 views
Posted on November 05, 2015 at 17:59

I'm interfacing with TI CC1101, it need to check MISO pin to low before start SPI transaction.

Shall I change MISO pin to AF mode to Input mode before I read, and then change it back to AF mode to start SPI.

Is  there a convenient way to do so ? ( I think GPIO_Init is a little overhead )

Or I can just read the pin as normal input pin in AF mode ?
    This topic has been closed for replies.

    4 replies

    waclawek.jan
    Super User
    November 5, 2015
    Posted on November 05, 2015 at 18:37

    And what does the RM (you did not tell us what STM32 model you have in mind) say, in Alternate function configuration sub-chapter of GPIO chapter, on read accesses to the input data register?

    JW

    Tesla DeLorean
    Guru
    November 5, 2015
    Posted on November 05, 2015 at 18:49

    I'd expect GPIOx->IDR would work transparently.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    thomfischer
    Senior
    November 5, 2015
    Posted on November 05, 2015 at 18:57

    Hello,

    which processor family ?,

    I am doing something comparable in STM32F4 with WS Signal on I2S interface.

    I just read the PIN which is configured in AF-mode as normal Input pin with

    HAL_GPIO_ReadPin().

    If you have a look at the

    Figure 25. Basic structure of a five-volt tolerant I/O port bit

    in reference manual ,

    you can see that the input signal goes parallel to the Alternate function input and the Input data register,

    so I think, that you always can read the state of a Pin, even if it is in AF-mode.

    best regards

    sprhawk
    sprhawkAuthor
    Associate II
    November 5, 2015
    Posted on November 05, 2015 at 20:41

    Thanks for all your replies.

    I will do just read pins.

    My processor is STM32F4 series