I2C question w/ MCP23017 Port Expanders


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Posts
    98

    Default I2C question w/ MCP23017 Port Expanders

    i am working on a project w/ 5 ea MCP23017 16 bit I2C port expanders
    the expander chips are spread across 4 different pcbs and are reading switches and driving status leds

    i have things working pretty well but there is a mystery which i hope someone can help me chase down

    conditions:
    PBP is v2.60, PM is 4.08
    PIC is 16F819
    20MHz ext cer res (running fine)
    using the I2CREAD and I2CWRITE commands
    pins chosen are the SDA and SCL hardware pins just in case i want to use the hardware I2C some day
    very weak pullups are at each port chip, 100K, the primary 10K pullups are at the source (not ideal i know but the runs are short)

    the mystery:
    ('3' and '4' below refer to the I2C address in decimal, 'A' & 'B' refer to the two 8 bit ports on the chip)
    PORT3B & 3A (expander port chip) is on pcb1, PIC is on pcb1 also
    PORT4B & 4A (expander port chip) is on pcb2

    when i read and write to 3A and/or 3B pcb1 everything is happy,
    when i add a line to write to 4B then the data on 3A gets scrambled, the added line is directly after the 3A Write and simply mimics the action on 3A on another port on another board with different bit polarities and bit positions

    if i REM the 4B I2CWRITE line all is well again

    i beat my head on this for quite a while (no I2C monitor at hand) and then FINALLY connected pcb2 (it had been disconnected prior) and then suddenly both 3 & 4 worked correctly !

    it has been my prior experience that with I2CREAD and I2CWRITE that you could do this 'open loop', i.e. if no slave chip was present the program would march on it's merry way without issues

    although it is working once connected i am not comfortable proceeding without getting to the bottom of this

    any thoughts or tips much appreciated, i hope this was clear

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: I2C question w/ MCP23017 Port Expanders

    your pull-up are far to be correct... at slow speed they need to be 4.7K or so... around 1.8k at higher speed.

    Begin with it.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Nov 2003
    Posts
    98


    Did you find this post helpful? Yes | No

    Default Re: I2C question w/ MCP23017 Port Expanders

    thanks mister_e,
    i will give that a try but i have never had much sensitivity to their value on other projects, will report back

    my suspicion is that when pcb2 is not connected the lack of response after writing to it has something to do with the issue

  4. #4
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: I2C question w/ MCP23017 Port Expanders

    The I2C protocol shouldn't work open loop. The slave must send an ACK after each byte that is written. I would be very surprised if the PBP routines for I2C were written in a way that did not wait for the slave ACK.

  5. #5
    Join Date
    Nov 2003
    Posts
    98


    Did you find this post helpful? Yes | No

    Default Re: I2C question w/ MCP23017 Port Expanders

    Hi Steve
    my understanding is that if there is an error with the ACK the program can jump to a location specified by an optional LABEL, if the optional LABEL is not given then the error is ignored

    are there examples here somewhere how to use the on chip hardware for I2C ?

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: I2C question w/ MCP23017 Port Expanders

    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Interfacing with Arduino I2C LCD
    By norohs in forum Documentation
    Replies: 47
    Last Post: - 30th May 2017, 18:53
  2. 16F1847 Usart and I2C
    By Seahound1 in forum Serial
    Replies: 6
    Last Post: - 18th December 2012, 20:41
  3. Strange I2C and serial behaviour.......
    By jimbostlawrence in forum General
    Replies: 4
    Last Post: - 30th October 2012, 01:02
  4. PIC 18F4550 and MCP23017
    By DaveC3 in forum Code Examples
    Replies: 12
    Last Post: - 4th December 2010, 14:01
  5. Question Regarding Port A on 16F876A
    By jevert in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 26th February 2009, 14:00

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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