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.| MCP23008 | MCP23017 | |
|---|---|---|
| Manufacturer | Microchip Technology | Microchip Technology |
| What it is | 8-bit I2C I/O expander with interrupt output | 16-bit I2C I/O expander with interrupt output |
| Registers | 11 | 21 |
| Buses | I2C | I2C |
| I²C addresses | 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27 | 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27 |
| Shared registers | 1 | 1 |
| Unique registers | 10 | 20 |
Same name, different behaviour
These registers exist on both parts but are not interchangeable. This is where a driver ported between them breaks quietly.
| Register | MCP23008 | MCP23017 |
|---|---|---|
| IOCON | 0x05 · 8-bit · reset 0x00 | 0x0A · 8-bit · reset 0x00 |
Only on the MCP23008
| Addr | Register | Description |
|---|---|---|
| 0x03 | DEFVAL | Default comparison value, used when INTCON selects comparison mode |
| 0x02 | GPINTEN | Interrupt-on-change enable, per pin |
| 0x09 | GPIO | Port value. Reading returns the pin state; writing modifies the output latch. |
| 0x06 | GPPU | 100 kOhm pull-up enable, per pin, on pins configured as inputs |
| 0x08 | INTCAP | Port value captured at the time of the interrupt. Cleared by reading INTCAP or GPIO. |
| 0x04 | INTCON | Interrupt control. 1 = compare against DEFVAL, 0 = compare against the previous value. |
| 0x07 | INTF | Interrupt flags. 1 = this pin caused the interrupt. Read-only. |
| 0x00 | IODIR | Pin direction. 1 = input, 0 = output. All pins are inputs after reset. |
| 0x01 | IPOL | Input polarity. 1 = the GPIO register reflects the inverted pin value. |
| 0x0A | OLAT | Output latch. Reading returns the latch, not the pin. |
Only on the MCP23017
| Addr | Register | Description |
|---|---|---|
| 0x06 | DEFVALA | Default comparison value, used when INTCON selects comparison mode (port A) |
| 0x07 | DEFVALB | Default comparison value, used when INTCON selects comparison mode (port B) |
| 0x04 | GPINTENA | Interrupt-on-change enable, per pin (port A) |
| 0x05 | GPINTENB | Interrupt-on-change enable, per pin (port B) |
| 0x12 | GPIOA | Port value. Reading returns the pin state; writing modifies the output latch. (port A) |
| 0x13 | GPIOB | Port value. Reading returns the pin state; writing modifies the output latch. (port B) |
| 0x0C | GPPUA | 100 kOhm pull-up enable, per pin, on pins configured as inputs (port A) |
| 0x0D | GPPUB | 100 kOhm pull-up enable, per pin, on pins configured as inputs (port B) |
| 0x10 | INTCAPA | Port value captured at the time of the interrupt. Cleared by reading INTCAP or GPIO. (port A) |
| 0x11 | INTCAPB | Port value captured at the time of the interrupt. Cleared by reading INTCAP or GPIO. (port B) |
| 0x08 | INTCONA | Interrupt control. 1 = compare against DEFVAL, 0 = compare against the previous value. (port A) |
| 0x09 | INTCONB | Interrupt control. 1 = compare against DEFVAL, 0 = compare against the previous value. (port B) |
| 0x0E | INTFA | Interrupt flags. 1 = this pin caused the interrupt. Read-only. (port A) |
| 0x0F | INTFB | Interrupt flags. 1 = this pin caused the interrupt. Read-only. (port B) |
| 0x00 | IODIRA | Pin direction. 1 = input, 0 = output. All pins are inputs after reset. (port A) |
| 0x01 | IODIRB | Pin direction. 1 = input, 0 = output. All pins are inputs after reset. (port B) |
| 0x02 | IPOLA | Input polarity. 1 = the GPIO register reflects the inverted pin value. (port A) |
| 0x03 | IPOLB | Input polarity. 1 = the GPIO register reflects the inverted pin value. (port B) |
| 0x14 | OLATA | Output latch. Reading returns the latch, not the pin. (port A) |
| 0x15 | OLATB | Output latch. Reading returns the latch, not the pin. (port B) |
Get either as C
regforge gen MCP23008 --out ./src --driver --tests
regforge gen MCP23017 --out ./src --driver --tests