• 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

    Oldhack-15978

    Num_Byte on 18F26K42

    Thread Starter: towlerg

    I'm using a macro that was created by the generator Dump Macro P1 #if (Prm_Count > 1) #error "Dump - Too many parameters" #else ...

    Oldhack Yesterday, 23:42 Go to last post
    John Drew-26

    Fault in bit wise comparisons on release 3.6.1.2.

    Thread Starter: kbaykar

    Hi Les, I just downloaded the release 3.6.1.2 today and seeing that it supports 18F47K40. I am trying to port my code from 18F4685 to 18F47K40. ...

    John Drew Yesterday, 13:41 Go to last post
    SimonJA-751

    Hx711 calibration

    Thread Starter: amod

    Iam using load cell amplifier HX711 module.I have got raw values from module but iam not able to calibrate with load cell.I want make a universal...

    SimonJA Yesterday, 07:38 Go to last post