dirk50
Posts: 3
Joined: Fri Feb 22, 2013 3:11 pm

understanding Read/Write PCF8575 with SmBus

Sun Feb 24, 2013 6:10 pm

I have a perfectly working pcf8574 on the I2C bus.
I'm trying to grasp the basic bus.write_byte() and bus.read_byte() commands for the pcf8574.
The 8574 datasheet is clear how to do that with the LSbit in the slave address as a R/W command.
http://html.alldatasheet.com/html-pdf/1 ... F8574.html
What I don't understand is how SmBus handles this, as there are only 2 arguments for a write instruction.
Q1: how do I set which lines are input or output, followed in the second step outputting the value?

Code: Select all

bus=SMBus(0)  # (in Python)
addr=0x38
bus.write_byte(addr, 0xff) # set P0-7 in output mode
bus.write_byte(addr, 0x01) # set P0=1  ??????? this doesn't work
Q2: Can I mix input and output, for example P0-3 input, P4-7 output followed by the correct writing and reading?
I would appreciate an example. After hours of Googling found nothing that quite answers these questions....

Thanks...
D.

Return to “Interfacing (DSI, CSI, I2C, etc.)”