0
\$\begingroup\$

We are connecting Raspberry Pi3B with some MCP23S17 expanders: MCP23S17.

I have read that they could emulate an open-drain outputs, playing with high Z state of the pin when configured as input. What kind of input and output those GPIOs are?

What about when it is a normal output by default? are they push-pull? I have seen that they normally are push pull output.

I would like to use that for continuity detection between two pins that could be or not in contact. So I would like to know what kind of things I must to do or connect there, when I will do some of these things:

1.- Could I connect an output pin to another input, write the output pin and read the input pin value?

2.- Does I need a special "connection-configuration" for achieving this function propperly?

According what I have been seen, it seems to be "open-drain" the best option, due push pull option it's said that it can't be connected with other IC pins. I'm not sure about this information.

So if anyone could clarify me these questions will be helpful.

\$\endgroup\$
3
  • \$\begingroup\$ What do you mean it can't be connected with other IC pins? \$\endgroup\$
    – Justme
    Jun 2, 2020 at 15:55
  • \$\begingroup\$ Hi @Justme this is what I was trying to clarify. It is something that I have read on some posts. I guess this was a vague way to say that you can't connect two pins having different potential values. \$\endgroup\$
    – Suvi_Eu
    Jun 3, 2020 at 8:29
  • \$\begingroup\$ I don't understand what that might mean, so please give a link to post that is confusing. It's a GPIO expander, it is meant to be connected to all kinds of things, including other chips, but of course within the limitations of each device and common sense. Like don't drive 5V into 3.3V chip if it does not tolerate 5V or don't connect two push-pull outputs together. \$\endgroup\$
    – Justme
    Jun 3, 2020 at 9:00

1 Answer 1

1
\$\begingroup\$

They are not different than many MCU GPIO pins. Unfortunately the datasheet has no block diagram at all to explain this.

The pins have direction control register to set the pin direction between input and output. Basically it just controls if the output buffer is enabled or disabled.

When output buffer is enabled, the pin is a push-pull output which drives the pin state high or low according to the output data register. When the output buffer is disabled, it is in high-z state, so it can act as an input pin, so another device can drive the pin.

The current state of the pin can always be read from the input register, whether it is an input or output.

There is also a pull-up enable register, which can enable an internal pull-up for a pin, to set it's state high if nothing else is connected. This removes the need for external pull-up resistors.

And finally, as the pin is completely under user control, it can be set to be either low output or high-z state, to emulate an open-drain IO pin.

1) Yes, you can connect one pin to another, and write the output pin and read input pin to see if they are connected together or not.

2) No, nothing special is needed. Just one input and one output is enough.

Open-drain can be used too, but you don't have to.

\$\endgroup\$
8
  • \$\begingroup\$ Thanks @Justme, it has helped me. \$\endgroup\$
    – Suvi_Eu
    Jun 3, 2020 at 8:30
  • \$\begingroup\$ Regarding inputs and ouptuts datasheet has another parameter that is omited. Typical electrical characteristics as input or output currents. It shows clamp input and output max current (about 20mA). If I want to be far from this value, I will put a KOhms resistor; but I would like to know what could be a typical current working value in order for not limiting too much the minimum current for working propperly. \$\endgroup\$
    – Suvi_Eu
    Jun 3, 2020 at 8:43
  • \$\begingroup\$ That does not sound right, unless you are abusing the chip with voltages beyond supply voltage limits, so it is protected by the internal clamps. What is it that you are connecting to? Note that the datasheet does mention how much current it can source and sink while keeping the output voltage within logic level specs, and it does mention input leakage and the curret via the pull-up too. \$\endgroup\$
    – Justme
    Jun 3, 2020 at 9:12
  • \$\begingroup\$ For example, first I would like to connect LEDs, they could be 10mA or 20mA, typically. But as I said, I will connect at every pin a wire from connectors that could be in a bank. We will detect if a GPIO pin is connected to GND, if two pins have some kind of connection (there could be some natural R between), but it could also some gpio could be dedicated to turn on LEDs (Only one this 3 actions for every pin at once). \$\endgroup\$
    – Suvi_Eu
    Jun 3, 2020 at 9:50
  • 1
    \$\begingroup\$ A GPIO input is like any othet CMOS input, virtually no current (except leakage current and, if enabled, pull-up current) flows when input voltage is withing limits. It's high impedance. Only if voltage goes beyond the limits, clamping diodes try to protect the part. \$\endgroup\$
    – Justme
    Jun 3, 2020 at 15:02

Your Answer

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

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