Overview
The MCP23S17 is an SPI 16-bit (two ports) bi-directional GPIO expansion chip. Its TWI version is the MCP23017. It's rich of functions, data direction, control, distinct input and output registers, programmable weak pull up resistors, interrupt capabilities etc. Its configuration setting is very similar to most of PIC micro-controller since it is produced by Microchip Technology.
It contains two 8-bit bi-directional port, GPA and GPB. Both of them are programmable with additional interrupt features. Its two interrupt flag pins correspond to each ports.
| MCP23S17-E/SP |
The SPI version of this chip is very similar to the I2C version.
Package Types |
Its SPI interface is bi-directional since it's a general purpose I/O chip. Its four SPI pins are Chip Select(CS), Serial Clock(SCK), Serial In(SI) and Serial Out(SO). Its three optional address pins are A2:A0. We can connect them to GND to set the SPI slave write address to 0x40 and 0x41 for read address.
![]() |
| Functional Block Diagram |
The programmer must configure the following registers to get a proper operation.
![]() |
| Register Addressed |
By default we don't set the IOCON register the default bank is BANK0 ranges from 0x00 to 0x15. For example the IODIRB locates at 0x01 and its output register OLATB locates at 0x15.
| SPI ADDRESSING REGISTERS |
The idle state of CS pin is high.
ATMega644 and MCP23S17 SPI Programming
The write operations contain three data bytes, slave write address, register address and data. For example to make GPIOA as output we must do the following step:
- Set CS pin low
- Send its slave address 0x40 (A2:A0=0)
- Send IODIRA address 0x00
- Send data direction 0x00 that is output direction
- Clear CS pin
The read operation also contains three data bytes, slave read address, register address, any data and read operation.



No comments:
Post a Comment