0

I bought a MCP23017 and doing some small test with it. I've made a simple Python script to make read_out of pin state. Can anyove explain to me, why i'm loosing a bit when GPIO_A7 is triggered? I've got 8 bit readout and all input changers state from 1 to 0 except GPIO_A7 so it looks like this:

GPIO_A0 = 11111110, GPIO_A1 = 11111101 But when hitting GPIO_A7 = 1111111

So i've only get 7 bit and not 8?

Hope for some help. :-)

    #!/usr/bin/env python
    #
    # Input / output MCP23017

    import smbus
    import sys
    import time

     bus = smbus.SMBus(1)
     once = False

     def start_up(once):
         if once != True:
         bus.write_byte_data(0x22, 0x00, 0xFF) # set input bank a
         time.sleep(0.1)
         bus.write_byte_data(0x22, 0x01, 0xFF) # set input bank b
         time.sleep(0.1)
         bus.write_byte_data(0x22, 0x0C, 0xFF) # set pull-up resistor
         time.sleep(0.1)
         bus.write_byte_data(0x22, 0x0D, 0xFF) # set pull-up resister
         time.sleep(0.1)
         once = True
    return once

    def read_data(bank):
        if bank == 0:
            state = bus.read_byte_data(0x22, 0x12)
            time.sleep(0.5)
         return state

    def main():
        start_up(once)
            while True:
            state = read_data(0)
        print bin(state)


    if __name__ == "__main__":
        main()
0

I haven't looked too carefully at your question but it seems to be related to a feature or bug or whatever you choose to call it of some MCP23017.

The answer seems to be don't use A7 or B7 as inputs.

See https://www.raspberrypi.org/forums/viewtopic.php?p=637787

0

I've figured it out. It's not a bug. Is it the conversion between Hex and Binary. I think is the way that Python do the conversion, that removing the first 0 and just show 1111111.

  • However this is still a known bug of the MCP23017. – joan Dec 11 '16 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.