interfacing with mcp23018 io expander via i2c

hello

i am having a confusing problem.

i am trying to get a 16 bit io expander chip to work with i2c.

When i send the output pin (olat) binary 1, i would expect it to have +vdd, and 0; n/c.

instead, 1= nc/ and 0= gnd

in the setup of my code, i set IOCON as 0x00 to select bank 1, i set IODIR = 0x00 as an output, and have even tried GPPU = 0xff for internal pullup resistor.

the really strange thing is that i have used the sister chip, mcp23008 which is similar but only 1 8 bit bank.

the only difference i can see is that the datasheet specifies the outputs as open drain. i don't understand what that means.

any ideas, thanks
doug

Go here for an explanation of Open Drain/Open Collector:

Basically, the output pin is connected to ground or it's open.
To have a positive voltage on the output you'll need a pullup
resistor tied from the output pin to some positive voltage,
usually Vcc or the voltage needed for whatever you're driving.

thanks

i have spent months trying to figure this out. i only read the open drain part recently, and with your explanation have been able to make it work.

i put a pullup resistor on the output pin, and an led between output pin and ground, and it works. I set the output resistor to limit the current through the led, and bob's your uncle.

thanks
doug

Attaboy! Glad I could help.