Software I2C and MCP23017 Port Expander


+ Reply to Thread
Results 1 to 2 of 2

Thread: Software I2C and MCP23017 Port Expander2841 days old

  1. #1
    Prolific Poster pic-ignorant's Avatar
    Join Date
    Oct 2007
    Posts
    2,938
    Thumbs Up
    Received: 25
    Given: 31
    Total Downloaded
    926.61 MB

    0 Not allowed!

    Default Software I2C and MCP23017 Port Expander

    Has anybody used a MCP23017 Port Expander with soft I2C commands? I'm only controlling a bunch of relays via a darlington array with it. The locations of the hardware SDA/SCL pins on the pic I'm using are not in a good place for my board layout, so I wondered if it is possible to allocate different pins, and use BusOut instead?


    Many thanks for anybodys help


    John

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Prolific Poster pic-ignorant's Avatar
    Join Date
    Oct 2007
    Posts
    2,938
    Thumbs Up
    Received: 25
    Given: 31
    Total Downloaded
    926.61 MB

    0 Not allowed!

    Default Re: Software I2C and MCP23017 Port Expander

    Hi John,

    Here is a bit of code that will help you. I used a Mchip I2C Demo board.




    Declare SDA_Pin PORTA.0 'PIN USED FOR DATA (CAN BE ANY GP PIN)
    Declare SCL_Pin PORTA.1 'PIN USED FOR CLOCK (CAN BE ANY GP PIN)
    Symbol MCPWRITE = %01000000 'BITS 7-4 = MCP23008 CONTROL CODE : BITS 3-1 = ADDRESS: BIT 0 = WRITE(0)
    Symbol MCPREAD = %01000001 'BITS 7-4 = MCP23008 CONTROL CODE : BITS 3-1 = ADDRESS: Bit 0 = READ(1)
    Symbol IODIR = 0x00 'SETS THE PORT TRIS
    Symbol GPIOA = 0x09 ' I/O PORT (THERE IS NO GPIOB ON A MCP23008)
    Symbol IOCON = 0x05 'GENERAL SET UP REGISTER
    Symbol GPPU = 0x06 'WEAK PULLUP REGISTER 0= OFF 1 = ON
    Symbol IPOL = 0x01 'A '1' FLIPS THE INPUT POLARITY OF THE SELECTED BIT
    Print At 1,1," I2C TEST"
    GoSub OUTPUT_INIT 'INITIALISE THE MCP23008
    'TOGGLES BETWEEN ODD & EVEN BITS(8 LEDS CONNECTED) ON GPIOA TO SHOW ITS WORKING
    LOOP:

    BusOut MCPWRITE,GPIOA,[%01010101]
    DelayMS 100
    BusOut MCPWRITE,GPIOA,[%10101010]
    DelayMS 100
    GoTo LOOP
    OUTPUT_INIT:
    BusOut MCPWRITE, IODIR,[%00000000]
    'SET ALL 8 BITS OF GPIOA TO OUTPUTS
    Return
    Regards John

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. MCP23017 port pin expander not working
      By Dave-S in forum Proton Plus Compiler v3
      Replies: 27
      Last Post: 13th April 2018, 17:49
    2. PCF8574 I2C port expander problem
      By Peter Truman in forum Proton Plus Compiler v3
      Replies: 12
      Last Post: 25th November 2012, 05:18
    3. [SOLVED !] Help please, advice re port expander for led drivers (I2C / SPI)
      By Kapitan in forum The Lounge
      Replies: 21
      Last Post: 29th June 2012, 11:05
    4. I2C Port Expander
      By belsenthegreat in forum The Lounge
      Replies: 5
      Last Post: 3rd February 2007, 13:14

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts