Page 1 of 1

I2C controlled port expansion

Posted: Thu May 07, 2009 5:18 am
by leonet99
I am trying to connect a couple of PCA9534 IO port expanders via I2C to a PIC18F4321 and I am using the Flowcode Pro v3.6.11 to which I am fairly new but I am even newer to I2C.
The comm speed is not important and there's no need to get back any interrupts as all the expanded ports will most likely be configured as digital outputs to drive some relays and status LEDs.
The picture attached only shows a portion of the schematic, the second port expander hardware address is 110.

Can I get any help or sample flowcode to get a primer on using/configuring the I2C feature to be able to control these expanded outputs?
Any help is greatly appreciated so please reply with anything that can help me put together the thoughts behind the I2C configuration and communication structure.

The port expander datasheet http://focus.ti.com/lit/ds/symlink/pca9534a.pdf has some good advise but I am not sure of how to use that info in combination with the flowcode feature.
Here's a portion of the schematic:
Port_expander.jpg
Port_expander.jpg (56.71 KiB) Viewed 4684 times

Re: I2C controlled port expansion

Posted: Thu May 07, 2009 12:54 pm
by Benj
Hello

I2C follows a simple communications structure. If you go into the Flowcode V3 fodler then you will find the I2C.hlp file. The I2C read and write structure is detailed towards the bottom of this file.

Note that the first address you send should involve the I2C hardware address and should take account of the read / write bit.

Looking at the device datasheet and the I2C EEPROM example on the Flowcode Examples page should help with getting the communications working correctly.

http://www.matrixmultimedia.com/Flowcode_Examples.php

Re: I2C controlled port expansion

Posted: Thu May 07, 2009 5:05 pm
by Dan81
Try this flowchart.

It is not tested (neither optimized).

Daniel

Re: I2C controlled port expansion

Posted: Thu May 07, 2009 10:37 pm
by leonet99
Thank you Ben and Dan81 for your prompt response.
I will give it a shot tonight and let you know about my progress.
This Flowcode is pretty exciting, I am glad to be aboard. :P