Skip to main content
VAvag.1
Associate III
April 14, 2022
Solved

Hi All. What will happen if try to toggle pin with alternate function. Controller will ignore this command?

  • April 14, 2022
  • 5 replies
  • 1420 views

..

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

    If the pin is in SPI mode, trying to toggle it will not affect SPI communication. But if it's initialized as GPIO last, then clearly SPI mode won't work.

    Unclear what "code written earlier" means exactly. Surely you can edit code to do what you want instead of what it did before. The order in which code is executed is going to affect things.

    5 replies

    Tesla DeLorean
    Guru
    April 14, 2022

    GPIO->ODR​ or BSRR ain't going to work if that's their question. The AF mux will determine who owns control

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    TDK
    April 14, 2022

    If a pin is in AF mode, the peripheral controls the pin state (input vs output) as well as its output state. ODR/BSRR is ignored in this case.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    VAvag.1
    VAvag.1Author
    Associate III
    April 14, 2022

    Thank You for response. I have activated SPI1 in f401re(nucleo board), but in code written earlier SCK was common GPIO, connected with LED, and this part of code wasn't commented. May it affect SPI functionality?

    TDK
    TDKBest answer
    April 14, 2022

    If the pin is in SPI mode, trying to toggle it will not affect SPI communication. But if it's initialized as GPIO last, then clearly SPI mode won't work.

    Unclear what "code written earlier" means exactly. Surely you can edit code to do what you want instead of what it did before. The order in which code is executed is going to affect things.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    VAvag.1
    VAvag.1Author
    Associate III
    April 14, 2022

    Thank You for answers.

    MM..1
    Chief III
    April 14, 2022

    If your code control LED ODR/BSRR no , but if you activate other AF as PWM then SPI AF will ovrride...

    VAvag.1
    VAvag.1Author
    Associate III
    April 18, 2022

    Thank You!