0
\$\begingroup\$

I'm designing a SPI based communiations circuit between Raspberry Pi4+B as a master and (n x 8) GPIO expander modules, as slaves. Concretely we have selected an MCP23S17 GPIO expander: Datasheet

By the moment I will try if the system is able to write 0 or 1 to the GPIO = outputs. After this, I will be testing the reading pin values from GPIO = inputs.

I would like to know if someone has worked with this, and I will also ask for some things if for example:

  1. I access any of the expansor modules and I write some output pins (1 or 0)
  2. After write operation we access another expansor modules for carry out any operation like the previous one

    • What happens with the first output pin value of the first operation? Does the expansor device keep the previous pins state even if the expansor module is not acceded (unselected) yet?

I have read datasheet and application notes. I don't find there any information that makes me think that the state is "erased" after being unselected.

  • I have another question about something read at datasheet. "each pin can be configured emulating open drain configuration" --> what does it mean? and for what is useful this option?

By the information that I've seen it's similar to use pull up/down, but getting more current. It can be also used for passing one level signal to another level signal, between CIs. But when is it better than using only pull up/down resistors? When can I get advantage of using a pin with this configuration?

Any help will be appreciated.

\$\endgroup\$
5
  • \$\begingroup\$ It would be polite to link to the GPIO datasheet in the question. I would find it surprising if there wasn't some mode where the pin state persisted until you rewrote it. (Should be easy to find explanations of "open drain" or similar "open collector") \$\endgroup\$
    – user16324
    May 28, 2020 at 16:28
  • 1
    \$\begingroup\$ I use these, and yes, they keep state. \$\endgroup\$
    – Ron Beyer
    May 28, 2020 at 16:40
  • \$\begingroup\$ Thanks @BrianDrummond, I've loaded the datashhet yet. \$\endgroup\$
    – Suvi_Eu
    May 29, 2020 at 12:01
  • \$\begingroup\$ Thanks @RonBeyer, this is useful for me. \$\endgroup\$
    – Suvi_Eu
    May 29, 2020 at 12:02
  • 1
    \$\begingroup\$ OK. The question has been answered, but I'll comment because reading datasheets is a learned skill... Here, the only relevant timing information is Fig 1.7 and Table 1.5 which show when GPIO outputs can change : Parameter 50. If they changed at other times there should be timing diagrams showing that : e.g. Fig 1.2,Reset. IMO there should be one showing what happens when the pin is setup as input or output, (via the IODIR registers) but I can't find it. \$\endgroup\$
    – user16324
    May 29, 2020 at 12:18

1 Answer 1

2
\$\begingroup\$

Any GPIO expander will keep the state it is set to, until it is set to a new state. It would be a pretty lousy expander if the pins changes to some other state while you access another device over the same bus.

The open drain emulation means that the IO pin can be set to push-pull output where it outputs high or low, or it can be used like an open-drain output, where it never outputs high, but can be set to output low and high impedance state.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks @Justme Just a question, when can I use this emulation for some GPIO pins? Is it useful or needed when you want to read from input "n" pin a written output "n+1" pin? that's said I have 2 pins with two wires and I want to know if two both wires are connected. I could write '1' to GPIO 'n' pin and then I could read from GPIO 'n+1' pin. If I read "1" that would mean that they are in contact, so continuity. Would you use open drain for this? \$\endgroup\$
    – Suvi_Eu
    Jun 2, 2020 at 11:30
  • \$\begingroup\$ It depends. Maybe I would, if there is a chance that setting the pin to output high is dangerous. Otherwise one pin can be output and the other one input. But I have no idea what you are doing and why, and it does not relate to your original question, so maybe open a new question about this. \$\endgroup\$
    – Justme
    Jun 2, 2020 at 13:47

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.