Expand Your I/O With The I²C Bus

Nov. 10, 2003
In system applications where various input signals are monitored or several output signals are controlled, these lines are sometimes connected directly to the microprocessor pins. Such monitoring and controlling is done in software. However, this...

In system applications where various input signals are monitored or several output signals are controlled, these lines are sometimes connected directly to the microprocessor pins. Such monitoring and controlling is done in software. However, this technique may require many microprocessor pins.

To conserve microprocessor pins, one alternative is to have the monitored and controlled lines communicate with the microprocessor through a glue-logic interface. In this case, fewer lines are connected to the microprocessor pins. But in either scenario, developing such systems is more cumbersome and time-consuming because it requires more devices, the routing of more traces, or the development of code that's more complex.

Here's a good solution for monitoring and controlling several peripheral signals. It provides a simple cost-effective method of accessing a parallel bus and a convenient means of interfacing with different electronic devices. The technique is based on the industry-standard PCF8574 and PCF8574A devices. These products differ in their inter-integrated circuit (I2C) addresses. This article refers to both devices as the expander. When discussing differences, the specific device is called by name.

The expanders have a two-wire I2C communication bus that can interface with an I2C master for bidirectional data transfers. The I2C bus consists of two active wires and a ground connection. The active wires are a bidirectional serial data (SDA) line and a bidirectional serial clock (SCL) line (Fig. 1). Both SDA and SCL are joined to a positive supply voltage via a pull-up resistor. When the bus is idle, both lines are pulled high.

Depending on its functionality, every device linked to the I2C bus has its own unique address and can act as a receiver and/or transmitter. The expanders can be configured to have a unique 7-bit address. The first four bits of the PCF8574's 7-bit address are 0100, and those for the PCF8574A are 0111. The lower three bits are the settings on device pins A2, A1, and A0. Therefore, the complete unique address of a device is determined by the setting on the A2, A1, and A0 pins. The table shows the unique addresses of the PCF8574 and PCF8574A for the various possible settings.

The ability to set unique addresses for the devices makes it possible to have up to eight PCF8574 and eight PCF8574A devices on the same I2C bus. As each device has eight I/O pins, a single I2C bus can control as many as 128 I/Os if PCF8574 and PCF8574A are employed.

I2C communication with the expanders is initiated by the master, which sends the address bits of the slave device to be communicated with. The first part of the address byte consists of a 4-bit address code, which is set to 0100 for the PCF8574 device and 0111 for the PCF8574A device. Three chip-select bits (A2, A1, and A0) follow the address code. These enable the use of up to eight PCF8574 and eight PCF8574A devices on one bus and determine which device is accessed. For the device to respond, the chip-select bits in the address byte must correspond to the logic levels on the corresponding A2, A1, and A0 pins. Figure 2 shows an example circuit that uses up to eight PCF8574 and eight PCF8574A devices to control and monitor up to 128 I/Os.

For additional information on using PCF8574 and PCF8574A, see Texas Instruments' application report, Improving System Interrupt Management Using the PCF8574 and PCF8574A I/O Expanders for the I2C Bus, literature number SCPA032.

Sponsored Recommendations

Near- and Far-Field Measurements

April 16, 2024
In this comprehensive application note, we delve into the methods of measuring the transmission (or reception) pattern, a key determinant of antenna gain, using a vector network...

DigiKey Factory Tomorrow Season 3: Sustainable Manufacturing

April 16, 2024
Industry 4.0 is helping manufacturers develop and integrate technologies such as AI, edge computing and connectivity for the factories of tomorrow. Learn more at DigiKey today...

Connectivity – The Backbone of Sustainable Automation

April 16, 2024
Advanced interfaces for signals, data, and electrical power are essential. They help save resources and costs when networking production equipment.

Empowered by Cutting-Edge Automation Technology: The Sustainable Journey

April 16, 2024
Advanced automation is key to efficient production and is a powerful tool for optimizing infrastructure and processes in terms of sustainability.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!