Jon Chandler
- 25th September 2004, 09:33
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
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