0

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.

Suvi_Eu
  • 777
  • 6
  • 19
  • What do you mean it can't be connected with other IC pins? – Justme Jun 02 '20 at 15:55
  • 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. – Suvi_Eu Jun 03 '20 at 08:29
  • 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. – Justme Jun 03 '20 at 09:00

1 Answers1

1

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.

Justme
  • 127,425
  • 3
  • 97
  • 261
  • Thanks @Justme, it has helped me. – Suvi_Eu Jun 03 '20 at 08:30
  • 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. – Suvi_Eu Jun 03 '20 at 08:43
  • 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. – Justme Jun 03 '20 at 09:12
  • 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). – Suvi_Eu Jun 03 '20 at 09:50
  • About datsheet mentions, is what I said first: 20mA. I want to have limited the current for being far under this value. So, limiting with Rs, as I use to do with other circuits. – Suvi_Eu Jun 03 '20 at 09:52
  • But you must understand the differences. The 20mA maximum is for clamping diodes that protect from over/undevoltages. You don't do a design that utilizes the clamping diodes under normal use, if you need clamping then you build external protection. Otherwise the GPIO output stage has a 25mA limit. But those are absolute maximum ratings that cause damage. The rated output low and high currents are far below that, 8mA and 3mA respectively, rated at 4.5V supply. – Justme Jun 03 '20 at 11:23
  • Maybe you are right. I don't understand this. I thought that loads connected to GPIO outputs can not exceed more than 8mA for working out of danger. And the same for inputs. I thought I must to ensure that GPIO input doesn't get more neither closer than 20mA, – Suvi_Eu Jun 03 '20 at 13:10
  • 1
    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. – Justme Jun 03 '20 at 15:02