

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 pinout and description:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | GPB0 | GPIO Port B, Bit 0 |
| 2 | GPB1 | GPIO Port B, Bit 1 |
| 3 | GPB2 | GPIO Port B, Bit 2 |
| 4 | GPB3 | GPIO Port B, Bit 3 |
| 5 | GPB4 | GPIO Port B, Bit 4 |
| 6 | GPB5 | GPIO Port B, Bit 5 |
| 7 | GPB6 | GPIO Port B, Bit 6 |
| 8 | GPB7 | GPIO Port B, Bit 7 |
| 9 | VSS | Ground (0V) |
| 10 | INTB | Interrupt output for Port B |
| 11 | INTA | Interrupt output for Port A |
| 12 | SCL/SCK | SPI Clock Input |
| 13 | SDA/SDI | SPI Data Input |
| 14 | A0 | Address Pin 0 (used for device addressing) |
| 15 | A1 | Address Pin 1 (used for device addressing) |
| 16 | A2 | Address Pin 2 (used for device addressing) |
| 17 | RESET | Active-low Reset Input |
| 18 | CS | Chip Select (Active Low) |
| 19 | SDO | SPI Data Output |
| 20 | VDD | Power Supply (1.8V to 5.5V) |
| 21 | GPA7 | GPIO Port A, Bit 7 |
| 22 | GPA6 | GPIO Port A, Bit 6 |
| 23 | GPA5 | GPIO Port A, Bit 5 |
| 24 | GPA4 | GPIO Port A, Bit 4 |
| 25 | GPA3 | GPIO Port A, Bit 3 |
| 26 | GPA2 | GPIO Port A, Bit 2 |
| 27 | GPA1 | GPIO Port A, Bit 1 |
| 28 | GPA0 | GPIO Port A, Bit 0 |
The MCP23S17 is straightforward to use in SPI-based systems. Below are the steps and considerations for integrating it into your circuit:
The MCP23S17 is configured by writing to its internal registers via SPI. Below is an example of how to configure the device using an Arduino UNO:
#include <SPI.h>
// Define MCP23S17 SPI settings
#define MCP23S17_CS 10 // Chip Select pin for MCP23S17
#define IOCON 0x0A // IOCON register address
#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
void setup() {
pinMode(MCP23S17_CS, OUTPUT);
digitalWrite(MCP23S17_CS, HIGH); // Set CS high to disable MCP23S17
SPI.begin(); // Initialize SPI
// Configure MCP23S17
digitalWrite(MCP23S17_CS, LOW); // Select MCP23S17
SPI.transfer(0x40); // Write opcode (0x40 = write, address = 0)
SPI.transfer(IOCON); // Select IOCON register
SPI.transfer(0x28); // Set IOCON (e.g., enable hardware addressing)
digitalWrite(MCP23S17_CS, HIGH); // Deselect MCP23S17
// Set Port A as output and Port B as input
digitalWrite(MCP23S17_CS, LOW);
SPI.transfer(0x40); // Write opcode
SPI.transfer(IODIRA); // Select IODIRA register
SPI.transfer(0x00); // Set all Port A pins as output
digitalWrite(MCP23S17_CS, HIGH);
digitalWrite(MCP23S17_CS, LOW);
SPI.transfer(0x40); // Write opcode
SPI.transfer(IODIRB); // Select IODIRB register
SPI.transfer(0xFF); // Set all Port B pins as input
digitalWrite(MCP23S17_CS, HIGH);
}
void loop() {
// Example: Toggle Port A pins
digitalWrite(MCP23S17_CS, LOW);
SPI.transfer(0x40); // Write opcode
SPI.transfer(GPIOA); // Select GPIOA register
SPI.transfer(0xFF); // Set all Port A pins high
digitalWrite(MCP23S17_CS, HIGH);
delay(500);
digitalWrite(MCP23S17_CS, LOW);
SPI.transfer(0x40); // Write opcode
SPI.transfer(GPIOA); // Select GPIOA register
SPI.transfer(0x00); // Set all Port A pins low
digitalWrite(MCP23S17_CS, HIGH);
delay(500);
}
No Response from MCP23S17:
Interrupts Not Triggering:
Incorrect GPIO Behavior:
Q: Can I use multiple MCP23S17 devices on the same SPI bus?
A