Shop OBEX P1 Docs P2 Docs Learn Events
Mcp23016 — Parallax Forums

Mcp23016

ArchiverArchiver Posts: 46,084
edited 2004-04-12 01:44 in General Discussion
If I write:

I2COUT SDA, Wr23016, GP0, [noparse][[/noparse]dataGP0] 'dataGP0 = %10101010 = 170

will that set the states of GP0.0 to GP0.7, i.e., 0, 2, 4 and 6 high, 1, 3, 5
and 7 low?

Same for GP1?

Sid


[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-04-10 21:57
    When writing to the MCP23016 you must set the DDR bits for each port.
    To make all the pins on GP0 outputs you would do this:

    I2COUT SDA, Wr23016, IODIR0, [noparse][[/noparse]%00000000]

    In the MCP23016 DDR registers, zero indicates an output (0 looks like
    O), one indicates an input (1 looks like I).

    After that, writing a 0 to a GPx port pin makes it low, 1 makes it high.
    So in your example below, writing %10101010 to GP0 would cause GP0.0,
    GP0.2, GP0.4, and GP0.6 to be low, the others to be high.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: Newzed@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=uyWBiR5gntY2KxVVFClmJvUc38xPSYU3A-Bn8ExPFKd-1A5pNPQ2P5jlFYjdJHgBV3E0MfSi]Newzed@a...[/url
    Sent: Saturday, April 10, 2004 3:38 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] MCP23016


    If I write:

    I2COUT SDA, Wr23016, GP0, [noparse][[/noparse]dataGP0] 'dataGP0 = %10101010 = 170

    will that set the states of GP0.0 to GP0.7, i.e., 0, 2, 4 and 6 high, 1,
    3, 5
    and 7 low?

    Same for GP1?

    Sid
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-12 01:01
    In a message dated 4/11/2004 7:32:54 PM Eastern Daylight Time,
    jwilliams@p... writes:


    > After that, writing a 0 to a GPx port pin makes it low, 1 makes it high.
    > So in your example below, writing %10101010 to GP0 would cause GP0.0,
    > GP0.2, GP0.4, and GP0.6 to be low, the others to be high.
    >
    >

    The data sheet says the bytes are send MSB. So if I send 1000 000 does the
    "1" go to GPO.0 or GP0.7? You would think it would go to GP0.0, like a shift
    register.

    Sid


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-12 01:44
    The transmission of the data is handled by I2COUT and has no affect on
    your data bytes. So long as you have everything configured properly,
    sending %10101010 will make bits GPx.1, GPx.3, GPx.5, and GPx.7 high,
    the others low.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: Newzed@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=nYBUsl8_vrDZp5wQEf-v0siOKLgPBhhOro2FlSSdURuFQQhK7aEhyC1M3IXyi1n8ehzVlQ]Newzed@a...[/url
    Sent: Sunday, April 11, 2004 7:02 PM
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] MCP23016


    In a message dated 4/11/2004 7:32:54 PM Eastern Daylight Time,
    jwilliams@p... writes:


    > After that, writing a 0 to a GPx port pin makes it low, 1 makes it
    > high. So in your example below, writing %10101010 to GP0 would cause
    > GP0.0, GP0.2, GP0.4, and GP0.6 to be low, the others to be high.
    >
    >

    The data sheet says the bytes are send MSB. So if I send 1000 000 does
    the
    "1" go to GPO.0 or GP0.7? You would think it would go to GP0.0, like a
    shift
    register.

    Sid
Sign In or Register to comment.