JayAuckland
New Member
Hi all,
I'm trying to read from the ports of an MCP23016. GP0 port inputs are all configured as inputs. GP1 has been configured as 7 input pins (GP1.0 - GP1.6) and one output pin (GP1.7).
I'm trying to read four or more inputs on GP1 to supplement the eight GP0 inputs to give me 12 inputs, with the eight GP0 inputs read to one PIC byte variable and four of the GP1 inputs (GP1.0 - GP1.3) to another byte; then read the two bytes as one word.
Unfortunately I get a garbled result with all kinds of unexpected numbers being displayed when I make any of the GP1 inputs high. There are pull-down resistors on all input pins including unused ones, and only one input at a time is ever high - I'm reading a 12-position rotary switch.
I've read the MCP23016 datasheet as insightfully as I can and I can't, for instance, see a way to mask the 1.7 input from that port, if indeed that is the cause of my problem.
I'm hoping someone can point me towards a solution!?!
Jay.
I'm trying to read from the ports of an MCP23016. GP0 port inputs are all configured as inputs. GP1 has been configured as 7 input pins (GP1.0 - GP1.6) and one output pin (GP1.7).
I'm trying to read four or more inputs on GP1 to supplement the eight GP0 inputs to give me 12 inputs, with the eight GP0 inputs read to one PIC byte variable and four of the GP1 inputs (GP1.0 - GP1.3) to another byte; then read the two bytes as one word.
Code:
#picaxe 14m2
setfreq m4
#no_data
pause 500 'allow time for LCD and driver to initialise
w4 = 0 'set retard value for watering timing
hi2csetup i2cmaster, 70, i2cfast, i2cbyte 'set i2c address to I/O expander 1
hi2cout 6, (%11111111) 'set IODIR0 to be all inputs
hi2cout 7, (%01111111) 'set IODIR1 to be all inputs except 1.7
Tst:
hi2cin 0, (b2) 'read GP0 port inputs
hi2cin 1, (b3) 'read GP1 port inputs
serout B.5, N2400_4, (254,192, " ", #w3, " ") 'display on LCD
goto Tst 'loop
I've read the MCP23016 datasheet as insightfully as I can and I can't, for instance, see a way to mask the 1.7 input from that port, if indeed that is the cause of my problem.
I'm hoping someone can point me towards a solution!?!
Jay.