MCP23016 I/O expander with PBP?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Jon Chandler's Avatar
    Jon Chandler Guest

    Default MCP23016 I/O expander with PBP?

    I'm trying to use a MCP23016 I/O expander with a 16F628 running at 20 MHz using I2C. No luck making it work but a Maxim LED driver sharing the I2C lines works great.

    I'm using Porta.0 and Porta.1 for the I2C interface. Each line has a 4.7k pullup resistor. All three address lines on the MCP23016 are tied low.

    I've got a DEFINE OSC 20 at the start of the program.

    My commands are as follow:

    First, I initialize the MCP23016 to make all pins outs:

    I2CWRITE porta.0,porta.1,%01000000,$06,[%00000000, %00000000] 'all outputs

    Then I try to cycle the outputs high and low:

    I2CWRITE porta.0,porta.1,%01000000,$00,[%11111111, %11111111] 'RELAYS ON

    PAUSE 5000

    I2CWRITE porta.0,porta.1,%01000000,$00,[%00000000, %00000000] 'RELAYS off

    pause 5000


    Looping through the on/off commands causes no changes on any of the outputs.

    The MCP23016 data sheet isn't entirely clear to me but I believe I just need to write data to the GP0 and GP1 registers without needing to do anything with the latch registers.

    Any ideas? Thanks!

    Jon

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


    Did you find this post helpful? Yes | No

    Default

    hi Jon,
    did you

    1. add COMCON1=0 at the begining of your program
    2. add PAUSE 100 at the begining (PWRT of MCP23016 need 72ms
    3. test CLK (pin 9) to see if oscillator work at about 1 MHZ
    4. use %0100000 instead of %01000000 (one zero less) for
    your address (that's what the datasheet says)
    5. add PAUSE 10 after each I2CWRITE
    6. write same to IODIR0 and IODIR1 registers
    7. Use DEFINE I2C_SLOW 1 (but your device is suppose to
    support fast I2C)


    the datasheet is indeed not to clear (like every microchip datasheet) but as i think you may need to latch your outputs. Try to do it at the begining

    I2CWRITE %0100000,$02,[$FF,$FF] ; LATCH OLAT0
    I2CWRITE %0100000,$03,[$FF,$FF] ; LATCH OLAT1

    i hope this will help.

    let me know

    Mister_e
    Steve

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

  3. #3
    scholar's Avatar
    scholar Guest


    Did you find this post helpful? Yes | No

    Default

    Hello, I am also developing the I/O expansion using MCP23016, and i use PIC16F77 as microcontroller. I am having problem to make it works also. Even with the code added as mentioned by you. Can anyone expalin briefly to me the steps required to make the MCP23016 work?

    A thousands thank you......

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. MCP23016 I2C serial I/O expander chip
    By GeoJoe in forum Serial
    Replies: 7
    Last Post: - 31st October 2007, 15:39
  3. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 19:01
  4. MCP23016 I/O expander
    By Demon in forum mel PIC BASIC Pro
    Replies: 42
    Last Post: - 24th October 2005, 01:01
  5. I2C I/O Expander PCF8574 hanging?
    By NavMicroSystems in forum Serial
    Replies: 12
    Last Post: - 4th August 2005, 02:26

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