Hi all,
Has anyone used the MCP23016 I/O expander with PBP? I can't seem to get the I2CREAD command to return anything. I'm using an 18F87J50. I have my LCD working and diagnostic LED's on my new board are all under control. I can see there is a bit stream on the data line that recurs on schedule. (I execute the I2CREAD command about every 5 seconds.)
Here is my code:
define osc 25
intcon = %10100000
intcon2 = %01000000
t0con = %11010101
rcon = %00000000
adcon0 = %00010001
adcon1 = %00001010
define lcd_dreg portd
define lcd_dbit 0
define lcd_rsreg porte
define lcd_rsbit 0
define lcd_ereg porte
define lcd_ebit 1
low porte.2
pause 500
define adc_bits 10
insin var word
insin = 0
Loop:
lcdout $fe, 1
lcdout "The lcd is working"
I2Cread portc.4, portc.3, %01000000, insin, noitwoc
lcdout $fe, $c0
lcdout dec insin
pause 5000
goto loop:
noitwoc:
lcdout $fe, 1
lcdout "no i2c ack"
pause 2000
goto loop
I have checked the schematic time and time again. It matches the I/O expander data sheet. and the data/clock pins match the code. I have measured the RC clock and it is running correctly. I have only tried the 3.9k and 33pF RC combo. I never get to the noitwoc loop so I ass'u'me I am recieving the acknowledge from the 23016. The 23016 spec sheet states that the chip is default to all inputs. But the variable insin never changes from 0 even if one or all pins are set high or low?
I am fairly certain that my problem is not hardware.
Any advice? Oh by the way the SFR's setup here work well with the 18F4525 setup to work with the LAB-X1 experimenter board. Except the dbit is 4 on the X1.
Thanks,
Joe
Bookmarks