I2C with MCP23016


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2010
    Posts
    12

    Default I2C with MCP23016

    Hi, i'm trying to get this IO expander chip to work with a 18F8720(have others in stock and same results), I wired the clock and i'm able to measure it at the TestPin of the MCP and i get a 1Mhz clock there, on the SDL, SCL lines(pulled up by 2 (4.7K resistors), i can see, something passing on my scope, but when the device does not put its port 0 to outputs and do not drive them, i think they are floating, in order of 2mV so nothing meanfull, tried to pull them up and down. But no luck.

    Here is the code i use

    ADCON0 = 0;
    ADCON1 = %00001111;
    DEFINE OSC 24
    DEFINE I2C_SLOW
    PAUSE 200
    ct var byte
    reg var byte
    val VAR BYTE
    ct = %01000000
    reg = $6
    val = 0
    ' Set direction for PORT0 to all outs
    I2CWrite PORTC.4,PORTC.3, ct,reg,[val]
    main:
    LOW PORTH.0
    reg = $0 'MCP23... IO LATCH
    val = 255
    I2CWrite PORTC.4,PORTC.3,ct,reg,[val]
    PAUSE 500
    HIGH PORTH.0
    reg = $0 'MCP IO LATCH
    val = 0
    I2CWrite PORTC.4,PORTC.3, ct,reg,[val]
    PAUSE 500
    goto main

  2. #2
    Join Date
    Apr 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    i got the code working by stripping the reg value and using a PCF8574 which has no clock circuit, and it worked directly, this lead me to re-analize the clock on the test pin of the MCP and i got a quite noisy signal, how can i get this more stable, i tried adding condos at the powersupply but still got noise on it. i assume that due to an unstable clock, the data is not handled right by the device.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You've not told us how your MCP23016 is connected.

    Do a SEARCH on MCP23016 on this forum - there are code examples.

  4. #4
    Join Date
    Apr 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Hi melanie,
    the mcp is on portc.3 and 4 for SDA SCL, and thats it. All vss & vdd's are connected and address pins are all grounded.
    I've seen those code samples and I inpired my code from them, but it doesn't want to work...grrrr. I don't get anything on the outputs of the MCP.
    I really think it is more a clock issue, on the MCP, than an I2C problem. I've tested other I2C devices and they work, they do not need an external RC.

    The datasheet says 33Pf and 3.9KOhms for a res and condo between clk pin of the mcp and VSS,VDD.
    That should give a 1Mhz clock on test pin, but that clock is very unstable here, and i can't clean it out.

    Regards

  5. #5
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    I ones worked with those chips, I only had it working without the 33 pF capacitor. The MCP23017 seems a better choice, it does not need an external capacitor.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink

    Hi, Sebastien

    an interesting reading: Microchip AN 245 ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Apr 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by eggman View Post
    I ones worked with those chips, I only had it working without the 33 pF capacitor. The MCP23017 seems a better choice, it does not need an external capacitor.
    Yeah I prefered the 17's but i could not grab that chip at my local store so gone for the 16. I will try without the cap. Thanks for that tip

    I'm now managing to do it with the philips component, but it has only 8, so i will have to make 2 other SDA, SCL lines.

  8. #8
    Join Date
    Apr 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Sebastien

    an interesting reading: Microchip AN 245 ...

    Alain
    Seen that appnote and did not find new info compared to the datasheet.
    But thanks anyway

Members who have read this thread : 1

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