Controlling MAX7311 port extender


Results 1 to 5 of 5

Threaded View

  1. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    It's a bit confusing, isn't it?

    The expanders "address" goes in the I2C Control byte, and the "command" goes in the Address byte.

    Read Input Ports:
    I2Cread PORTB.2,PORTB.3,64,0,[switch(0),switch(1)]

    Write Output Ports:
    I2Cwrite PORTB.2,PORTB.3,64,2,[switch(0),switch(1)]

    Set Port Configuration:
    PE_TRIS VAR BYTE[2] ; bitwise - 1=input 0=output
    PE_TRIS(0) = 255    ; Port1 all input
    PE_TRIS(1) = 0      ; Port2 all output

    I2Cwrite PORTB.2,PORTB.3,64,6,[PE_TRIS(0),PE_TRIS(1)]
    How do I set the 2nd MAX7311's Port1/Port2 registers to output?
    For a second Expander, you would tie pin <strike>AD1</strike> AD0 to Vdd to change it's slave address to 66. Then you can use it just like the first one.

    Read Input Ports:
    I2Cread PORTB.2,PORTB.3,66,0,[switch(0),switch(1)]

    Set Port Configuration: (all output)
    I2Cwrite PORTB.2,PORTB.3,66,6,[0,0]

    HTH,
    Last edited by Darrel Taylor; - 26th November 2006 at 23:33. Reason: Fixed AD0 Typo
    DT

Similar Threads

  1. Why (or how to) make a port array for OW
    By Roy___ in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd February 2009, 23:30
  2. Change On Interrupt, PIC16F884
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 14th November 2008, 17:25
  3. port config.
    By tamertokgoz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th July 2008, 12:25
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. STATUS re-curtain W
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 15:21

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