Skip to main content
Explorer
November 28, 2023
Question

Blocking a GPIO pin to LOW state

  • November 28, 2023
  • 2 replies
  • 1000 views

Hi, I have a circuit in which I want to check every cycle if a measured voltage is over a limit value and in that case disable the measure over one of four DUTs forcing to LOW the state of some pins. The problem is that in the main loop I have command line that set the state of the pin sometimes to high and sometimes to low and I would to find a way to block the state of a pin and do not change his state until the end of the program. I thought to use the IF but I have 4 DUTs to check and control separately.

    This topic has been closed for replies.

    2 replies

    Super User
    November 28, 2023

    You haven't told us which STM32 and which pins, so just a vague answer:

    One of the tricks could be setting the pin to AF to a peripheral which can hold it low, e.g. timer. After that, writes to  GPIOx_ODR (directly or through GPIOx_BSRR) won't be reflected on the pin's state.

    Nonetheless, this is not something you can click in CubeMX.

    JW

    Super User
    November 28, 2023

    Can't you implement this in program logic?

    If out of bounds, don't change pin state.

    I don't see how having 4 pins like this changes anything. If you have an array for them, you can do the check there. If not, four separate statements will work.