The MCP23X08 device provides 8-bit, general
purpose, parallel I/O expansion for I
applications. The two devices differ in the number of
hardware address pins and the serial interface:
2
• MCP23008 – I
• MCP23S08 – SPI interface; two address pins
The MCP23X08 consists of multiple 8-bit configuration
registers for input, output and polarity selection. The
system master can enable the I/Os as either inputs or
outputs by writi ng the I/O configur ation bits. The data
for each input or output is kept in the corresponding
Input or Output register. The polarity of the Input Port
register can be inverted with the Polarity Inversion
register . All registers ca n be read by the sy stem maste r.
C interface; three address pins
2
C bus or SPI
The interrupt output can be configured to activate
under two conditions (mutually exclusive):
1.When any input state differs from its
corresponding input port register state. This is
used to indicate to the system master that an
input state has changed.
2.When an input stat e differs from a preconfigure d
register value (DEFVAL register).
The Interrupt Capture register captures port values at
the time of the interrupt, thereby saving the condition
that caused the interrupt.
The Power-on Reset (POR) sets the registers to their
default values and initi ali zes the device state mach in e.
The hardware address pins are used to determine the
device address.
1.1Pin Descriptions
TABLE 1-1:PINOUT DESCRIPTION
Pin
Name
SCL/SCK11ISerial clock input.
SDA/SI22I/OSerial data I/O (MCP23008)/Serial data input (MCP23S08).
A2/SO33I/OHardware address input (MCP23008)/Serial data output (MCP23S08).
A144IHardware address input. Must be biased externally.
A055IHardware address input. Must be biased externally.
RESET
NC/CS77INo connect (MCP23008)/External chip select input (MCP23S08).
INT88OInterrupt output. Can be configured for active-high, active-low or open-drain.
SS99PGround.
V
GP01012I/OBidirectional I/O pin. Can be enabled for interrupt -on-change an d/or interna l weak
GP11113I/OBidirectional I/O pin. Can be enabled for interrupt -on-change an d/or interna l weak
GP21214I/OBidirectional I/O pin. Can be enabled for interrupt -on-change an d/or interna l weak
GP31315I/OBidirectional I/O pin. Can be enabled for interrupt -on-change an d/or interna l weak
GP41416I/OBidirectional I/O pin. Can be enabled for interrupt -on-change an d/or interna l weak
GP51517I/OBidirectional I/O pin. Can be enabled for interrupt -on-change an d/or interna l weak
GP61618I/OBidirectional I/O pin. Can be enabled for interrupt -on-change an d/or interna l weak
GP71719I/OBidirectional I/O pin. Can be enabled for interrupt -on-change an d/or interna l weak
The on-chip P OR c ircui t ho lds the device in r eset unt il
DD has reached a high enough voltage to deactivate
V
the POR circuit (i.e., release the device from reset).
The maximum VDD rise time is specified in Section 2.0“Electrical Characteristics”.
When the device exits the POR condition (releases
reset), device operating parameters (i.e., voltage,
temperature, serial bus frequen cy, etc.) must be met to
ensure proper operation.
1.3Serial Interface
This block handles the functionality of the I2C
(MCP23008) or SPI (MCP23S08) interface protocol.
The MCP23X08 contains eleven registers that can be
addressed through the serial interface block (Table 1-2):
The Sequential Operation (SEQOP) bit (IOCON
register) controls the operation of the address pointer.
The address pointer can either be enabled (default) to
allow the address pointer to increment automatically
after each data transfer, or it can be disabled.
When operating in Sequential mode
(IOCON.SEQOP = 0), the address pointer automatically increments to the next address after each byte
is clocked.
When operating in Byte mode (IOCON.SEQOP = 1),
the MCP23X08 does not increment its address
counter after each byte during the data transfer. This
gives the ability to contin ually read the same address
by providing extra clocks (without additional control
bytes). This is useful for polling the GPIO register for
data changes.
1.3.2I2C™ INTERFACE
1.3.2.1I
The I2C Write operation includes the control byte and
register address sequence, as shown in the bottom of
Figure 1-1. This sequence is followed by eight bits of
data from the master and an Acknowledge (ACK) from
the MCP23008. The operation is ended with a STOP
or RESTART condition being generated by the master.
Data is written to the MCP23008 after every byte
transfer. If a STOP or RESTART condition is
generated during a data transfer, the data will not be
written to the MCP23008.
Byte writes and sequential writes are both supported
by the MCP23008. The MCP23008 increments its
address counter after each ACK during the data
transfer.
2
C Write Operation
1.3.2.2I2C Read Operation
The I2C Read operation includes the control byte
sequence, as shown in the bottom of Figure 1-1. This
sequence is followed by another control byte (including the START condition and ACK) with the R/W bit
equal to a logic 1 (R/W = 1). The MCP23008 then
transmits the data contained in the addressed register.
The sequence is ended with the master generating a
STOP or RESTART condition.
1.3.2.3I2C Sequential Write/Read
For sequential operations (Write or Read), instead of
transmitting a STOP or RESTART condition after the
data transfer , the master cl ocks the next byte pointe d to
by the address pointe r (see Section 1.3.1 “Sequ entialOperation Bit” for details regarding sequential
operation control).
The sequence ends with the master sendin g a STOP or
REST AR T co ndi tio n.
The MCP23008 address pointer will roll over to
address zero after reaching the last register address.
Refer to Figure 1-1.
1.3.3SPI™ INTERFACE
1.3.3.1SPI Write Operation
The SPI Write opera tion is st arted by lowe ring CS . The
Write command (slave address with R/W bit cleared) is
then clocked into the dev ice. The opcod e is followed by
an address and at least one data byte.
1.3.3.2SPI Read Operation
The SPI Read operation is st arted by lowe ring CS. The
SPI read command (slave address with R/W bit set) is
then clocked into the dev ice. The opcod e is followed by
an address, with at least one data byte being clocked
out of the device.
The hardware address pins are used to determine the
device address. To address a device, the corresponding address bits in the control byte must match the pin
state.
• MCP23008 has address pins A2, A1 and A0.
• MCP23S08 has address pins A1 and A0.
The pins must be biased externally.
MCP23008/MCP23S08
1.4.1ADDRESSING I2C DEVICES
(MCP23008)
The MCP23008 is a slave I2C device that supports 7-bit
slave addressing, with the read/write bit filling out the
control byte. The slave address contains fo ur fixed bits
and three user-defined hardware address bits (pins A2,
A1 and A0). Figure 1-2 shows the control byte format.
1.4.2ADDRESSING SPI DEVICES
(MCP23S08)
The MCP23S08 is a slave SPI device. The slave
address contains five fixed bits and two user-defined
hardware address bits (pins A1 and A0), with the
read/write bit filling out the control byte. Figure 1-3
shows the control byte format.
The GPIO module contains the data port (GPIO),
internal pull up resistors and the Output Latches
(OLAT).
1.6Configuration and Control
Registers
The Configuration and Control blocks contain the
registers as shown in Table 1-3.
Reading the GPIO regi ster read s the va lue on th e port.
Reading the OLAT register only reads the OLAT, not
the actual value on the port.
Writing to the GPIO register actually causes a write to
the OLAT. Writing to the OLAT register forces the
associated output drivers to drive to the level in OLAT.
Pins configured as inpu ts turn of f the ass ociated outp ut
driver and put it in high-impedance.
The IPOL register allows the user to configure the
polarity on the corresponding GPIO port bits.
If a bit is set, the corresponding GPIO register bit will
reflect the inverted va lue on the pin.
REGISTER 1-2:IPOL – INPUT POLARITY PORT REGISTER (ADDR 0x01)
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0
IP7IP6IP5IP4IP3IP2IP1IP0
bit 7bit 0
bit 7-0IP7:IP0: These bits control the polarity inversion of the input pins <7:0>.
1 = GPIO register bit will reflect the opposite logic state of the input pin.
0 = GPIO register bit will reflect the same logic state of the input pin.
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
1.6.3INTERRUPT-ON-CHANGE
CONTROL (GPINTEN) REGISTER
The GPINTEN register controls the interrupt-onchange feature for each pin.
If a bit is set, the corresponding pin is enabled for
interrupt-on-change. The DEFVAL and INTCON
registers must also be configured if any pins are
enabled for interrupt-on-change.
1.6.4DEFAULT COMPARE (DEFVAL)
REGISTER FOR INTERRUPT-ONCHANGE
The default comparison value is configured in the
DEFVAL register. If enabled (via GPINTEN and
INTCON) to compare against the DEFVAL register, an
opposite value on the associated pin will cause an
interrupt to occur .
REGISTER 1-4:DEFVAL – DEFAULT VALUE REGISTER (ADDR 0x03)
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0
DEF7DEF6DEF5DEF4DEF3DEF2DEF1DEF0
bit 7bit 0
bit 7-0DEF7:DEF0: These bits set the compare value for pin s configured for interrupt-on-ch ange from
defaults <7:0>. Refer to INTCON.
If the associated pin level is the opposite from the register bit, an interrupt occurs.
Refer to INTCON and GPINTEN.
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
The INTCON register controls how the associated pin
value is compared for the interrupt-on-change feature.
If a bit is set, the corresponding I/O pin is compared
against the associated bit in the DEFVAL register. If a
bit value is clear, the corresponding I/O pin is
compared against the previous value.
REGISTER 1-5:INTCON – INTERRUPT-ON-CHANGE CONTROL REGISTER (ADDR 0x04)
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0
IOC7IOC6IOC5IOC4IOC3IOC2IOC1IOC0
bit 7bit 0
bit 7-0IOC7:IOC0: These bits control how the associated pin value is compared for interrupt-on-
change <7:0>.
1 = Controls how the associated pin value is compared for interrupt-on-change.
0 = Pin value is compared against the previous pin value.
Refer to INTCON and GPINTEN.
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown