PCA9538 I2C IO Expander

This 8-bit I/O expander for the two-line bidirectional bus (I2C) is designed for 2.3-V to 5.5-V VCC operation. It provides general-purpose remote I/O expansion for most microcontroller families via the I2C interface [serial clock (SCL), serial data (SDA)].

Features

  • Low Standby Current Consumption of 1 µA Max
  • I2C to Parallel Port Expander
  • Open-Drain Active-Low Interrupt Output
  • Active-Low Reset Input
  • Operating Power-Supply Voltage Range of 2.3 V to 5.5 V
  • 5-V Tolerant I/O Ports
  • 400-kHz Fast I2C Bus
  • Two Hardware Address Pins Allow up to Four Devices on the I2C/SMBus
  • Input/Output Configuration Register
  • Polarity Inversion Register
  • Noise Filter on SCL/SDA Inputs

#include "mbed.h"
#include "PCA9538.h"

//PCA9538 MyExpand(p9,p10,0x70,p21);
DigitalOut myled(LED1);
DigitalOut myled2(LED2);
PCA9538PinOut myled3(exp_p4,p9,p10,0x70);
PCA9538PinOut myled4(exp_p7,p9,p10,0x70);
PCA9538PinIn  mypuls(exp_p0,p9,p10,0x70);
//void vISRExpand(void);

int main() {
    //MyExpand.vInit(0x0F,&vISRExpand);
    //MyExpand.vWrite(0x00);
    while(1) {
        if(mypuls==0){
            myled2=1;
            wait(0.3);
            myled2=0;
            wait(0.3);
        }else{
            myled3=1;
            myled4=1;
            myled=myled3;
            wait(0.5);
            myled = 0;
            myled3=0;
            myled4=0;
            wait(0.5);
        }
    }
}


/*void vISRExpand(void){

    myled2=!myled2;
    MyExpand.vWrite(MyExpand.cRead()<<4);
}*/

» Import this programPCA9538_example

Example PCA9538 I2C Expander

/media/uploads/Suky/pca9538.png

Library:

» Import this library into a programPCA9538_Expander

PCA9538 I2C Expander





3 comments:

30 Jan 2012

Where can I find PCA9538.h so I can include it into my program?

30 Jan 2012

Hello, PCA9538.h is in library right above or click http://mbed.org/users/Suky/libraries/PCA9538_Expander/llznq2.

31 Jan 2012

Thanks, this is my first program using the mbed (and using C++) so it's a steep learning curve!

One other question, is there any way to get rid of the compiler warning on this function:

PCA9534PinOut& PCA9534PinOut::operator= (int value){ vWrite(value); } This generates a "missing return statement at end of non-void function" warning.

I know it's only a warning but I don't like warnings.