MCP23S17 addressable 16-Bit I/O Expander with SPI
I'm working on an mbed library for the MicroChip MCP23S17. The library is currently at version 0.4; expect the API to change incompatibly until v 1.0. (See below).
Verison 0.4 adds a method to configure input pull-ups.
The chip has several advantages over my usual port expander, the PCF8574. It's 16 bits wide, and you can drive it at 10Mz. the PCF8574 is a first-generation I2C device so it is limited to a 100Kz clock rate. This means that the MCP23S17's clock rate is 100 times faster!
Best of all, although it uses SPI, the MCP23S17 is addressable just like an I2C slave. (Indeed there is a sister product MCP23017 with the same functionality but driven by I2C). You can have up to 8 individually addressable devices driven by the 3 SPI signals and a single chip select.
Most methods can access Port A or B depending on the port parameter value.
I've also changed the names of the _input _and _output _methods to _read _and _write_, so they will be more consistent with other libraries.
The latest library version supports 8-bit input and output, and also handles interrupt generation. You can
- configure interrupts on both ports
- turn interrupt mirroring on and off
- set interrupt polarity
- interrupt on change or difference from a specified value, and
- configure pull-ups to be on or off for each input pin.
The API is nearly complete, but there are no doxygen comments yet. I will add them when the API has stabilised.
This test breadboard layout, courtesy of Fritzing, is slightly out of date; see comments in the test for the full list of connections
I'll update the diagram when the API is complete.
1 comment on MCP23S17 addressable 16-Bit I/O Expander with SPI:
Please log in to post comments.