If I want to use GPIO pins of two microcontrolles as a mean of simple communication (e.g. reporting an event by sending 1 or 0), Do I need to enable internal pull up or pull down resistors on any of the MCUs?

I Want to put 2xSTM32 on the same board and need a way to signal the other chip that something has happened. I want to do this using a single GPIO pin on each device (hence no I2C/SPI/etc.)

enter image description here

Can you please tell me how what configuration should I do to the GPIO on each side? e.g.

GPIO Mode = output push-pull OR output open drain?
Pull Up/Down = Pull up or pull down or NONE?

GPIO Mode = input mode
Pull Up/Down = Pull up or pull down or NONE?

I mean what is the difference between push-pull and open drain and what will enabling pull up or pull down resistors do anyways?


1 Answer 1


The configuration I would use:

GPIO Mode = output push-pull
Pull Up/Down = no PU/PD

GPIO Mode = input mode
Pull Up/Down = opposite of logic high signal

And here is why:

The output as push-pull has generally the benefit, that it will drive the line in either way and ensure a good signal integrity. So even if your line gets a bit longer and the capacity might be a bit higher you usually don't suffer too much from it.

On the input side, you have to take into account (in my opinion) that you don't know if the sender will actually be there or if the line might be broken or not. So you should provide a way to ensure a stable logic level on that input even if the sender is absent or the line is broken. For that you use the pull up or pull down resistors. Depending on your physical layer specification (read: is your signal active low or active high) I would activate the pull resistor to the inactive signal level.

If your signal is active low, use a pull up, if it is active high, use a pull down.

To be more precise, the pull resistor should pull the signal to the safe state. Consider a write protect pin for example. Pull it in the direction that the write protection is enabled.

For this purpose the internal pull resistors are usually fine, just make sure to set them before you do any handling of the pin level.

An open drain output has only the ability to pull a line low, but it cannot drive the line high. This is commonly used on lines where multiple chips might want to signal something on the same line. Each chip can pull the line low, but no chip is driving it high, so no short circuit will happen.

Something has to drive the line high however and that is a pull up resistor. Pull up and Pull down are named like this because they will "pull" the voltage level of a line in the respective direction (high -> supply voltage, low -> ground, usually). The value of the resistor is chosen in such a way that no damaging current will flow in any device, no excessive current is flowing while the line is driven in the other direction and so that the line will return to the pulled level in the correct amount of time (depends on the capacity of the line).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.