• PicŪ Basic


  • Port expansion using the MCP23S17-2

    The MCP23S17 device provides 16-bit, general purpose parallel I/O expansion for SPI bus applications.
    The MCP23S17 consists of multiple 8-bit configuration registers for input, output and polarity selection.

    The MCP23S17 SPI expander works the same way as the I2C model MCP23017. Please download and read the documentation of the MCP23017 and the MCP23S08.
    More documentation is available here: http://www.protonbasic.co.uk/content...-using-the-MCP.
    All code written by me in all the libraries expanders is based on Les Johnson's code.

    I present two libraries to use with the MCP23S17 SPI expander.
    The first library uses hardware MSSP module of the PIC(r). (immovable pins) (MCP23S17-H.inc)
    The second library uses software to create a dialogue on the SPI bus. (configurable pins) (MCP23S17-S.inc)
    In the file "MCP23S17-S.inc", 3 types of code can be used for software SPI communication.

    How to use the hardware library see the "MCP23S17-H" folder.
    How to use the software library see the "MCP23S17-S" folder.

    In the MCP23S17-H folder: Using the MSSP module of the PIC(r).
    Test_MCP23S17_16.BAS
    Testing the expander in inquiry mode with 16-bit commands because it is more efficient.

    In 8-bit mode:
    Test_MCP23S17_INT8-A.BAS
    Testing the expander in interrupt mode with INTCON bit = 0 (double interrupt) with 2 INT pins.
    Test_MCP23S17_INT8-C.BAS
    Testing the expander in interrupt mode with INTCON bit = 1 (single interrupt) with 2 INT pins.

    In 16-bit mode:
    Test_MCP23S17_INT16A.BAS
    Testing the expander in interrupt mode with INTCON bit = 0 (double interrupt) with 1 INT pin.
    Test_MCP23S17_INT16B.BAS
    Testing the expander in interrupt mode with INTCON bit = 0 (double interrupt) with 1 INT pin and less control code: with real speed.
    Test_MCP23S17_INT16C.BAS
    Testing the expander in interrupt mode with INTCON bit = 1 (single interrupt) with 1 INT pin.
    Test_MCP23S17_INT16D.BAS
    Testing the expander in interrupt mode with INTCON bit = 1 (single interrupt) with 1 INT pin and less control code: with real speed.

    In the MCP23S17-S folder: Using the I2C software. Same as above.

    CONCLUSION:
    The qualities and limitations are the same as the MCP23017 I2C expander.
    The MCP23S17 SPI expander is complicated, versatile and configurable.
    I hope this work will help to use the MCP23S17 more easily.
    Alberto Freixanet

    MCP23S17_library.zip
  • Recent Activity

    xldaedalus-432

    Mysterious PORTB problem

    Thread Starter: xldaedalus

    I'm using Proton+ to develop firmware for a product with switches. The MCU is an 18F26K22. Most of the switches reside on PORTB. I am NOT using a...

    xldaedalus Today, 03:21 Go to last post
    tumbleweed-20435

    PIC18F1330 PLL problem

    Thread Starter: rcurl

    I'm just starting out on a new project that uses a PIC18F1330. I haven't used this specific chip before, so I began by trying to blink an LED just...

    tumbleweed Today, 11:13 Go to last post
    See_Mos-247

    Pic16f18877 oread

    Thread Starter: evoortman

    Hi, On a PIC16F18877 the OREAD command doesn't seem to work. The code is working on a PIC16F1939. Both controllers use 32MHz int osc. If i...

    See_Mos Today, 11:19 Go to last post
    towlerg-21522

    Lin bus and auto baud detection

    Thread Starter: Tim

    Lin bus looks to be a great system for an application i'm working on. One of the main things is the slave can be really simple without needing a...

    towlerg Yesterday, 15:13 Go to last post