

The MCP23S17 is a 16-bit I/O expander with an SPI (Serial Peripheral Interface) communication interface. It is designed to expand the number of GPIO (General Purpose Input/Output) pins available in microcontroller-based applications. The device features two 8-bit ports (PORTA and PORTB), which can be individually configured as input or output. Additionally, it supports interrupt-on-change functionality, making it ideal for applications requiring event-driven input monitoring.








The MCP23S17 is a versatile and robust I/O expander. Below are its key technical details:
| Parameter | Value |
|---|---|
| Operating Voltage (VDD) | 1.8V to 5.5V |
| Communication Interface | SPI (up to 10 MHz) |
| GPIO Pins | 16 (split into two 8-bit ports) |
| GPIO Voltage Levels | 0V to VDD |
| Interrupt Pins | 2 (INTA, INTB) |
| Maximum Sink Current | 25 mA per pin |
| Maximum Source Current | 25 mA per pin |
| Package Options | PDIP, SOIC, SSOP, QFN |
| Operating Temperature | -40°C to +125°C |
The MCP23S17 has 28 pins. Below is the pin configuration and description:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | A0 | Address pin 0 (used for device addressing) |
| 2 | A1 | Address pin 1 (used for device addressing) |
| 3 | A2 | Address pin 2 (used for device addressing) |
| 4 | RESET | Active-low reset input |
| 5 | CS | Chip Select (active-low) |
| 6 | SCK | SPI Clock input |
| 7 | SI | SPI Data input |
| 8 | SO | SPI Data output |
| 9 | VSS | Ground |
| 10-17 | GPA0-GPA7 | GPIO Port A pins |
| 18-25 | GPB0-GPB7 | GPIO Port B pins |
| 26 | INTA | Interrupt output for Port A (active-low) |
| 27 | INTB | Interrupt output for Port B (active-low) |
| 28 | VDD | Power supply input |
The MCP23S17 is straightforward to use in a circuit. Below are the steps and considerations for integrating it into your project:
The MCP23S17 is configured using its internal registers. Below is an example of how to configure the device using an Arduino UNO:
#include <SPI.h>
// MCP23S17 SPI commands
#define OPCODE_WRITE 0x40 // Write command opcode
#define OPCODE_READ 0x41 // Read command opcode
// MCP23S17 register addresses
#define IODIRA 0x00 // I/O direction register for Port A
#define IODIRB 0x01 // I/O direction register for Port B
#define GPIOA 0x12 // GPIO register for Port A
#define GPIOB 0x13 // GPIO register for Port B
// Chip Select pin for MCP23S17
const int CS_PIN = 10;
void setup() {
// Initialize SPI and Chip Select pin
SPI.begin();
pinMode(CS_PIN, OUTPUT);
digitalWrite(CS_PIN, HIGH);
// Configure MCP23S17
configureMCP23S17();
}
void loop() {
// Example: Toggle GPIOA0 every second
digitalWrite(CS_PIN, LOW);
SPI.transfer(OPCODE_WRITE); // Send write opcode
SPI.transfer(GPIOA); // Select GPIOA register
SPI.transfer(0x01); // Set GPA0 high
digitalWrite(CS_PIN, HIGH);
delay(1000);
digitalWrite(CS_PIN, LOW);
SPI.transfer(OPCODE_WRITE); // Send write opcode
SPI.transfer(GPIOA); // Select GPIOA register
SPI.transfer(0x00); // Set GPA0 low
digitalWrite(CS_PIN, HIGH);
delay(1000);
}
void configureMCP23S17() {
// Set all pins on Port A and Port B as outputs
digitalWrite(CS_PIN, LOW);
SPI.transfer(OPCODE_WRITE); // Send write opcode
SPI.transfer(IODIRA); // Select IODIRA register
SPI.transfer(0x00); // Set all pins on Port A as outputs
digitalWrite(CS_PIN, HIGH);
digitalWrite(CS_PIN, LOW);
SPI.transfer(OPCODE_WRITE); // Send write opcode
SPI.transfer(IODIRB); // Select IODIRB register
SPI.transfer(0x00); // Set all pins on Port B as outputs
digitalWrite(CS_PIN, HIGH);
}
No Response from MCP23S17:
GPIO Pins Not Responding:
Interrupts Not Triggering:
By following this documentation, you can effectively integrate the MCP23S17 into your projects and expand your microcontroller's GPIO capabilities.