I2C controlled port expansion

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
User avatar
leonet99
Posts: 8
Joined: Fri Apr 10, 2009 1:30 am
Contact:

I2C controlled port expansion

Post 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 4404 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: I2C controlled port expansion

Post 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

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: I2C controlled port expansion

Post by Dan81 »

Try this flowchart.

It is not tested (neither optimized).

Daniel
Attachments
i2c_forum.fcf
(6.5 KiB) Downloaded 453 times

User avatar
leonet99
Posts: 8
Joined: Fri Apr 10, 2009 1:30 am
Contact:

Re: I2C controlled port expansion

Post 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

Post Reply