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
The IOCON register contains several bits for
configuring the device:
• The Sequential Operation (SEQOP) controls the
incrementing function of the address pointer. If
the address pointer is disabled, the address
pointer does not automatically increment after
each byte is clocked during a serial transfer. This
feature is useful when i t is desire d to c ontinu ously
poll (read) or modify (write) a register.
• The Slew Rate (DISSLW) bit controls the slew
rate function on the SDA pin. If enabled, the SDA
slew rate will be controlled when driving from a
high to a low.
• The Hardware Address Enable (HAEN) cont rol bit
enables/disables the hardware address pins (A2,
A1) on the MCP23S0 8. Thi s bit i s not u sed o n the
MCP23008. The addres s pins are a lways enable d
on the MCP23008.
• The Open-Drain (ODR) control bit
enables/disables the INT pin for open-drain
configuration.
• The Interrupt Polarity (INTPOL) control bit sets
the polarity of the INT pin. This bit is functional
only when the ODR bit is cleared, configuring the
INT pin as active push-pull.
The GPPU register control s the pull-up resistors for the
port pins. If a bit is set and the corresponding pin is
configured as an input, the corresponding port pin is
internally pulled up with a 100 kΩ resistor.
The INTF register reflects the interrupt condition on the
port pins of any pin that is enabled for interrupts via the
GPINTEN register. A ‘set’ bit indicates that the
associated pin caused the interrupt.
This register is ‘read-o nly’. W rites to this regis ter will be
ignored.
Note:INTF will always reflect the pin(s) that
have an interrupt condition. For example,
one pin causes a n interrup t to occur and is
captured in INTCAP and INF. If, before
clearing the interrupt, ano ther pin change s
which would normally cause an interrupt, it
will be reflected in INTF, but not INTCAP.
REGISTER 1-8:INTF – INTERRUPT FLAG REGISTER (ADDR 0x07)
R-0R-0R-0R-0R-0R-0R-0R-0
INT7INT6INT5INT4INT3INT2INT1INT0
bit 7bit 0
bit 7-0INT7:INT0: These bits reflect the interrupt condition on the port. Will reflect the change only if
interrupts are enabled (GPINTE N) <7:0>.
1 = Pin caused interrupt.
0 = Interrupt not pending.
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 INTCAP register captures the GPIO port value at
the time the interrupt occurred. The register is ‘readonly’ and is updated o nly when an in terrupt occurs. Th e
register will remain unchanged until the interrupt is
cleared via a read of INTCA P or GPIO.
REGISTER 1-9:INTCAP – INTERRUPT CAPTURED VALUE FOR PORT REGISTER
(ADDR 0x08)
R-xR-xR-xR-xR-xR-xR-xR-x
ICP7ICP6ICP5ICP4ICP3ICP2ICP1ICP0
bit 7bit 0
bit 7-0ICP7:ICP0: These bits reflect the logic level on the port pins at the time of interrupt due to pin
change <7:0>.
1 = Logic-high.
0 = Logic-low.
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 GPIO register reflects the value on the port.
Reading from this reg ister reads the port. Writin g to this
register modifies the Output Latch (OLAT) register.
REGISTER 1-10:GPIO – GENERAL PURPOSE I/O PORT REGISTER (ADDR 0x09)
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0
GP7GP6GP5GP4GP3GP2GP1GP0
bit 7bit 0
bit 7-0GP7:GP0: These bits reflect the logic level on the pins <7:0>.
1 = Logic-high.
0 = Logic-low.
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 OLAT register provides access to the output
latches. A read from this regi ster results in a read of the
OLAT and not the port itself. A write to this register
modifies the output latches that modify the pins
configured as outputs.
The interrupt output pin will activate if an internal
interrupt occurs. The interrupt block is configured by
the following registers:
• GPINTEN – enables the individual inputs
• DEFVAL – holds the values that are compared
against the associated input port values
• INTCON – controls if the input values are
compared ag ainst DE FVAL or the previous value s
on the port
• IOCON (ODR and INPOL) – configures the INT
pin as push-pull, open-drain and active-level
Only pins configured as inputs can cause interrupts.
Pins configured as outputs have no affect on INT.
Interrupt activity on the po rt w i ll cau se th e p ort v al ue to
be captured and copied into INTCAP. The interrupt will
remain active until the INTCAP or GPIO register is
read. Writing to these registers will not affect the
interrupt.
The first interrupt event will cause the port contents to
be copied into the INTCAP register. Subsequent
interrupt conditions on the port will not cause an
interrupt to occur as long as the interrupt is not cleare d
by a read of INTCAP or GPIO.
FIGURE 1-6:INTERRUPT-ON-PIN-
CHANGE
GPx
INTACTIVEACTIVE
Port value
is captured
into INTCAP
Read GPIU
or INTCAP
Port value
is captured
into INTCAP
FIGURE 1-7:INTERRUPT-ON-CHANGE
FROM REGISTER
DEFAULT
DEFVAL
76543210GP:
XXXXX0XX
GP2
1.7.1INTERRUPT CONDITIONS
There are two possible configurations to cause
interrupts (configured via INTCON):
1.Pins configured for interrupt-on-pin-change
will cause an interrupt to occur if a pin changes
to the opposite state. The default state is reset
after an interrupt occurs. For example, an
interrupt occurs by an input changing from 1 to
0. The new initial state for the pin is a logic 0.
2.Pins configured for interrupt-on-change from
register value will cause an interrupt to occur if
the corresponding input pin differs from the
register bit. The i nterrupt condition will remain as
long as the condition exists, regardless if the
INTAP or GPIO is read.
See Figure 1-6 and Figure 1-7 for more information on
interrupt operations.
INT
Port value
is captured
into INTCAP
ACTIVE
ACTIVE
Read GPIU
or INTCAP
(INT clears only if interrupt
condition does not exist.)
Ambient temperature under bias.............................................................................................................-40°C to +125°C
Storage temperature.............................................................................................................................. -65°C to +150°C
Voltage on V
Voltage on all other pins with respect to V
Total power dissipation (Note) .............................................................................................................................700 mW
Maximum current out of V
Maximum current into V
Input clamp current, I
Output clamp current, I
Maximum output current sunk by any output pin ....................................................................................................25 mA
Maximum output current sourced by any output pin...............................................................................................25 mA
Note:Power dissipation is calculated as follows :
†
NOTICE: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating onl y and funct ional ope ration of the device at tho se or any other co nditio ns above those
indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for
extended periods may affect device reliability.
DD with respect to VSS ......................................................................................................... -0.3V to +5.5V
SS (except VDD) .............................................................-0.6V to (VDD + 0.6V)
SS pin...........................................................................................................................150 mA
DD pin..............................................................................................................................125 mA
IK (VI < 0 or VI > VDD)......................................................................................................................±20 mA
OK (VO < 0 or VO > VDD).............................................................................................................. ±20 mA
DIS = VDD x {IDD - ∑ IOH} + ∑ {(VDD-VOH) x IOH} + ∑(VOL x IOL)
YYear code (last digit of calendar year)
YYYear code (last 2 digits of calendar year)
WWWeek code (week of January 1 is week ‘01’)
NNNAlphanumeric trac ea bil ity code
3
e
Pb-free JEDEC designator for Matte Tin (Sn)
*This package is Pb- free. The Pb-free JEDEC designator ()
can be found on the outer packaging for this package.
Note:In the event the full Microchip part nu mber ca nnot be m arked o n one lin e, it will
be carried over to the next line, thus limiting the number of available
characters for customer-specific information.
Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
.010” (0.254mm) per side.
JEDEC Equivalent: MS-001
Drawing No. C04-007
18-Lead Plastic Small Outline (SO) – Wide, 300 mil (SOIC)
p
B
n
45°
c
β
E1
E
D
2
1
h
A
φ
L
A1
α
A2
MILLIMETERSINCHES*Units
Number of Pins
Pitch
Foot Angle
Lead Thickness
Mold Draft Angle Top
Mold Draft Angle Bottom
* Controlling Parameter
§ Significant Characteristic
Notes:
Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
.010” (0.254mm) per side.
JEDEC Equivalent: MS-013
Drawing No. C04-051
* While these devices are only offered in the “E”
temperature range, the device will operate at different
voltages and temperatures as identified in the
Section 2.0 “Electrical Characteristics”.
SO =Plastic SOIC (300 mil Body), 18-Lead
SS=SSOP, (209 mil Body, 5.30 mm), 20-Lead
Note the following details of the code protection feature on Microchip devices:
•Microchip products meet the specification contained in their particular Microchip Data Sheet.
•Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
•There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•Microchip is willing to work with the customer who is concerned about the integrity of their code.
•Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are com mitted to continuously improving the code protect ion f eatures of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digit al Mill ennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED,
WRITTEN OR ORAL, STATUTORY OR OTHERWISE,
RELATED TO THE INFORMATION, INCLUDING BUT NOT
LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE,
MERCHANTABILITY OR FITNESS FOR PURPOSE.
Microchip disclaims all liability arising from this information and
its use. Use of M icrochip’s prod ucts as critical components in
life support systems is not authorized except with express
written approval by Microchip. No licenses are conveyed,
implicitly or otherwise, under any Microchip intellectual property
rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, K
EELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart, rfPIC, and SmartShunt are
registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
PICMASTER, SEEVAL, SmartSensor and The Embedded
Control Solutions Company are registered trademarks of
Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, dsPICDEM,
dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR,
FanSense, FlexROM, fuzzyLAB, In-Circuit Serial
Programmin g, IC SP, ICEPIC, MPASM, MPLIB, MPLIN K,
MPSIM, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail,
PowerCal, PowerInfo, PowerMate, PowerTool, rfLAB,
rfPICDEM, Select Mode, Smart Serial, SmartT el, Total
Endurance and WiperLock are trademarks of Microchip
Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip T echnology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
Microchip received ISO/TS-16949:2002 quality system certification for
its worldwide headquarters, design and wafer fabrication facilities in
Chandler and Tempe, Arizona and Mountain View, California in
October 2003. The Company’s quality system processes and
procedures are for its PICmicro
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.