RegForge

Comparisons / MCP23008 vs MCP23017

MCP23008 vs MCP23017

Register-level differences, generated from both maps.

They cannot share an I²C bus by default. Both answer on 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27. Re-strap one, use a multiplexer, or put them on separate buses.
MCP23008MCP23017
ManufacturerMicrochip TechnologyMicrochip Technology
What it is8-bit I2C I/O expander with interrupt output16-bit I2C I/O expander with interrupt output
Registers1121
BusesI2CI2C
I²C addresses0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x270x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27
Shared registers11
Unique registers1020

Same name, different behaviour

These registers exist on both parts but are not interchangeable. This is where a driver ported between them breaks quietly.

RegisterMCP23008MCP23017
IOCON0x05 · 8-bit · reset 0x000x0A · 8-bit · reset 0x00

Only on the MCP23008

AddrRegisterDescription
0x03DEFVALDefault comparison value, used when INTCON selects comparison mode
0x02GPINTENInterrupt-on-change enable, per pin
0x09GPIOPort value. Reading returns the pin state; writing modifies the output latch.
0x06GPPU100 kOhm pull-up enable, per pin, on pins configured as inputs
0x08INTCAPPort value captured at the time of the interrupt. Cleared by reading INTCAP or GPIO.
0x04INTCONInterrupt control. 1 = compare against DEFVAL, 0 = compare against the previous value.
0x07INTFInterrupt flags. 1 = this pin caused the interrupt. Read-only.
0x00IODIRPin direction. 1 = input, 0 = output. All pins are inputs after reset.
0x01IPOLInput polarity. 1 = the GPIO register reflects the inverted pin value.
0x0AOLATOutput latch. Reading returns the latch, not the pin.

Full MCP23008 register map

Only on the MCP23017

AddrRegisterDescription
0x06DEFVALADefault comparison value, used when INTCON selects comparison mode (port A)
0x07DEFVALBDefault comparison value, used when INTCON selects comparison mode (port B)
0x04GPINTENAInterrupt-on-change enable, per pin (port A)
0x05GPINTENBInterrupt-on-change enable, per pin (port B)
0x12GPIOAPort value. Reading returns the pin state; writing modifies the output latch. (port A)
0x13GPIOBPort value. Reading returns the pin state; writing modifies the output latch. (port B)
0x0CGPPUA100 kOhm pull-up enable, per pin, on pins configured as inputs (port A)
0x0DGPPUB100 kOhm pull-up enable, per pin, on pins configured as inputs (port B)
0x10INTCAPAPort value captured at the time of the interrupt. Cleared by reading INTCAP or GPIO. (port A)
0x11INTCAPBPort value captured at the time of the interrupt. Cleared by reading INTCAP or GPIO. (port B)
0x08INTCONAInterrupt control. 1 = compare against DEFVAL, 0 = compare against the previous value. (port A)
0x09INTCONBInterrupt control. 1 = compare against DEFVAL, 0 = compare against the previous value. (port B)
0x0EINTFAInterrupt flags. 1 = this pin caused the interrupt. Read-only. (port A)
0x0FINTFBInterrupt flags. 1 = this pin caused the interrupt. Read-only. (port B)
0x00IODIRAPin direction. 1 = input, 0 = output. All pins are inputs after reset. (port A)
0x01IODIRBPin direction. 1 = input, 0 = output. All pins are inputs after reset. (port B)
0x02IPOLAInput polarity. 1 = the GPIO register reflects the inverted pin value. (port A)
0x03IPOLBInput polarity. 1 = the GPIO register reflects the inverted pin value. (port B)
0x14OLATAOutput latch. Reading returns the latch, not the pin. (port A)
0x15OLATBOutput latch. Reading returns the latch, not the pin. (port B)

Full MCP23017 register map

Get either as C

regforge gen MCP23008 --out ./src --driver --tests
regforge gen MCP23017 --out ./src --driver --tests