I2C for me?

Hi, I've been trying to understand I2C and have searched both this forum and read and reread blogs and examples, but I still don't understand it.

http://www.nxp.com/documents/data_sheet/PCF8577C.pdf

I would like to talk to this chip. However the playground examples and examples on other web sites all seem to use the same generic code examples. I would like to know how you map the pins in the code to do what you want them to.

For example. If I wanted the pins to control a 7 seg raw lcd display. I wanted pins s1 - s6 to control the a~g of the 7 seg. How would I figure out how to define them in the code and then once they are defined how would I get the bus to send that info?

I don't want to give up on I2C but it may be beyond my skill set at this time. :'(

I2C is a communication bus that uses 4 wires, +5V and GND, and SDA (serial Data) and SCL (Serial Clock). The latter two are specific for I2C.

Multiple devices can be connected to an I2C bus. Every device has its own address (like a street with houses). To communicate with the right device you call its “housenumber” over the bus so the device knows the next commands are his/hers (are I2C devices male or female?) .

On page 5 of the spec of PCF8577C.pdf paragraph 6.1 there is some talk about addressing. By connecting these pinsd to GND or +5V you can set the address of the chip.

The chip contains registers that represent the IO pins.
Fig 8 on page 8 shows how to control them:

1st send a byte with the address, (fig 6 page 8)
2nd send a control byte (fig 3 page 6)
3rd send byte(s) to fill the registers (table 1 and 2 page 9)

Note Table 1 shows both the control byte and the registers

First try to fill the first register to see what happens. Connect leds to pins S1…S8 (with approp resistor) and send the following 3 bytes

<00000000><01010101> (bytes in binary format) half the leds should glow,

sending

<00000000><10101010> should make the other half glow

Now attach more leds (all 32 pins) and try to set all registers.

<00000000><10101010> <00000010><10101010> <00000100><10101010> <00000110><10101010>

If this works you have made big progress.

The last 4 commands can be combined into one by sending multiple bytes in one command

<00000000><10101010><10101010><10101010><10101010> To understand how this works read paragraph 6.4

Hopes this gets you started. Read chapter 6 carefully as it is the core explanation. Succes,
Rob

Thanks Rob it does get me started. I wasn’t understanding the tables. I didn’t understand where they got the bits from and how they were arranged. The one table confused me because I didn’t realize that it also had the bank and register, but now it makes sense. Thanks, now back to experimenting.