Did you get this working? An interesting chip, but talk about lack of documentation...I am trying to figure out the difference between latched data and pin data. Chad --- In , Jon Chandler <chandler@s...> wrote: > Has anyone used the MCP23016 I/O expander with PicBasic Pro? > > I'm trying to control the MCP23016 using the I2CWRITE command, using > porta.0 and porta.1. All three MCP23016 address lines are tied to > ground. I know the I2C routine works because I'm also controlling a MAX > LED driver chip and it's working great. > > 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 > > As far as I can tell, nothing happens. I've tried writing to a single > register at a time with no luck either. > > It looks like I only need to write to GP0 and GP1, the general purpose I/O > port registers and I shouldn't have to do anything with the Output latch > registers. Is this correct? > > The PIC has a 20 MHz crystal, with DEFINE OSC 20 at the start of the program. > > Any ideas why this isn't working? Thanks in advance for the help! > > Jon |
Re: Microchip MCP23016 with PicBasic Pro?
Started by ●October 2, 2004
Reply by ●October 3, 20042004-10-03
--- In , Jon Chandler <chandler@s...> wrote: > Has anyone used the MCP23016 I/O expander with PicBasic Pro? > > I'm trying to control the MCP23016 using the I2CWRITE command, using > porta.0 and porta.1. All three MCP23016 address lines are tied to > ground. I know the I2C routine works because I'm also controlling a MAX > LED driver chip and it's working great. > > 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 > > As far as I can tell, nothing happens. I've tried writing to a single > register at a time with no luck either. > > It looks like I only need to write to GP0 and GP1, the general purpose I/O > port registers and I shouldn't have to do anything with the Output latch > registers. Is this correct? > > The PIC has a 20 MHz crystal, with DEFINE OSC 20 at the start of the program. > > Any ideas why this isn't working? Thanks in advance for the help! > > Jon What pins are you connecting to the chip ? not just comm lines, but address lines, TO, CLk, INT ? TP is open, is your address the on the chip correct for the serial address from your PIC ? And does your RC on CLK come close to the data sheet ? Dave |
Reply by ●October 4, 20042004-10-04
Chad, I'm still working on this. There are a couple points I can add. The first is that laying out an I2C bus is perhaps not a trivial exercise. The original circuit with the MAX chip worked fine on a bread-board, I didn't give the layout much thought. Turns out there is an I2C spec by Phillips with some good advice on trace arrangement and capacitive loading issues. My data and clock pulses were rounding quite a bit, so I decreased the pullup resistors to 2.4k, which has improved things a bit. The second issues has to do with PicBasic Pro. Rather than put values in the I2CWRITE command, they recommend using previously dimensioned variables. Apparently values can get interpreted in different ways which some I2C parts don't recognize. I found some information at this link, in the FAQ section: http://www.picbasic.co.uk/forum/ The rest of my I2C parts should arrive tomorrow which will let me try the circuit in its entirety. Hopefully it will all come together! I'll let you know what I find, especially regarding the need to do something with the latch registers. Jon >________________________________________________________________________ > Date: Sun, 03 Oct 2004 00:51:35 -0000 > From: "Chad Russel" <> >Subject: Re: Microchip MCP23016 with PicBasic Pro? >Did you get this working? An interesting chip, but talk about lack of >documentation...I am trying to figure out the difference between >latched data and pin data. > >Chad >--- In , Jon Chandler <chandler@s...> wrote: > > Has anyone used the MCP23016 I/O expander with PicBasic Pro? > > > > I'm trying to control the MCP23016 using the I2CWRITE command, using > > porta.0 and porta.1. All three MCP23016 address lines are tied to > > ground. I know the I2C routine works because I'm also controlling a >MAX > > LED driver chip and it's working great. > > > > 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 > > > > As far as I can tell, nothing happens. I've tried writing to a single > > register at a time with no luck either. > > > > It looks like I only need to write to GP0 and GP1, the general >purpose I/O > > port registers and I shouldn't have to do anything with the Output >latch > > registers. Is this correct? > > > > The PIC has a 20 MHz crystal, with DEFINE OSC 20 at the start of the >program. > > > > Any ideas why this isn't working? Thanks in advance for the help! > > > > Jon |
Reply by ●November 24, 20042004-11-24
Has anyone used the MCP23016 I/O expander with PicBasic Pro? I'm trying to control the MCP23016 using the I2CWRITE command, using porta.0 and porta.1. All three MCP23016 address lines are tied to ground. I know the I2C routine works because I'm also controlling a MAX LED driver chip and it's working great. 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 As far as I can tell, nothing happens. I've tried writing to a single register at a time with no luck either. It looks like I only need to write to GP0 and GP1, the general purpose I/O port registers and I shouldn't have to do anything with the Output latch registers. Is this correct? The PIC has a 20 MHz crystal, with DEFINE OSC 20 at the start of the program. Any ideas why this isn't working? Thanks in advance for the help! Jon |
|