ff-mcp23s17 Project Started
I started a project to control the MCP23S17 GPIO expander chip with FlashForth over SPI. If you need lots of I/O lines in a project, one approach is to attach to a microcontroller that has a lot of GPIO pins. Sometimes however you might have some reason to use a particular MC with less built-in lines, and in this case you can instead use a GPIO expander chip. The MCP23S17 has the following features:
- 16 GPIO pins which can be configured, read, and written to over SPI (or I2C). So only requires four (or three) lines from the MC to the expander chip. This makes cable management easy, for example, if you are connecting a Nano to a board that has the expander chips.
- You can have as many expander chips as you want, sharing the bus and clock lines.
- Inputs can be configured with pull-up resistors.
- Change interrupt pins
- Available in a DIP package, if you aren't setup to deal with SMT soldering
The downside is since it is serial communication, you have to spend some extra cycles just transferring data. But MCP23S17 supports 5 Mhz SPI, and anyway with many GPIO applications you don't need to check or modify the GPIO lines at a super high frequency.
So far, I haven't gotten much further than setting up the repository, writing the SPI initialization code, and setting up some code to control the Chip Select lines. It seemed a likely enough scenario in this case that someone might be using more than one expander chip on a board, so I have to take that into account while writing the code.
The ff-mcp23s17 code repository