MCP23S17 SPI Port Expander module(s)

Post here if you want to announce new wiki modules, projects or articles

Moderators: David Barker, Jerry Messina

Post Reply
User avatar
octal
Registered User
Registered User
Posts: 586
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

MCP23S17 SPI Port Expander module(s)

Post by octal » Sun Aug 10, 2008 11:01 pm

Hello,
Just wanted to let you know that I uploaded a set of modules on the wiki (http://www.sfcompiler.co.uk/wiki/pmwiki ... er.Modules) that handles Microchip 16 pins SPI Port expander MCP23S17.


This is a pre-version of a working module I worked on some months ago, and for personal health reasons, I never got time to work on it again.

In this article, I'm publishing two modules dealing with the Microchip MCP23S17 (SPI) port expander.
* first module handles only one MCP23S17 module. It's usefull when you need only one module in your design.
* the second module handles multiple MCP23S17 modules in the same circuit.

Why two modules? simply because in the case of multiple modules, you have to pass an additional parameter to all routines: the additional param is the chip physical address. The single MCP23S17 module does not have this param in its routines, and thus, let you save some precious ram bytes that you may need for other stuff.

Main Features:
1- Handle one or multiple MCP23S17 modules.
2- Use Hardware or Software SPI to manage the modules. Software SPI is usefull for little PICs that does not have SPI hardware module (like the little 18 pins 18F1320 mcu).
3- Most of functions/subs make the MCP chip act as additional PIC ports.
4- MCP chips are handled as two 8 bit ports.
5- All routines to read/write registers are available.

What's not handled:

- This is really a pre-version. Next version of the driver (under devlopment) handles also Interrupts.

Actually, interrupts can be handled by reading/writing concerned registers, it will be used transparently in upcomming drivers.

Note: This module is a working module, but is not fully optimized as my main concern, the time I was developing it, was to have something working for GLCD stuff. Next version will handle everything and will also offer other important stuff:
- Full support for SEQUENTIAL writing/reading, for reading/writing arrays of data
- Full support for SPI and I2C version of this chips. Switching from SPI to I2C version will be done by selecting only one OPTION !
-Full support of Pin inversion
...

This work has been done very quickly, when I was working on GLCD through SPI expander support. Instead of keeping all that on my PC, I prefer to share it in case anyone has urgent need to it. I'll also post all my GLCD stuff with all comments on results in the article session in next couple of days.


For any comment, or feedback (or bug report), please post to Swordfish Forum.


I hope you can find this helpfull.


Best regards
octal

Post Reply