I2C and PCF8574 problems...

Status
Not open for further replies.

juanperez

Member
Hello friend!

I have a little big problem with the i2c bus and various PCF chips. Specifically I have 3 chips with addresses 0x38, 0x39 and 0x3b. They are detected correctly, but when I run the code it seems that it is stuck when it finishes writing to the i2c bus.
I show you my code here:

Code:
void initPCF() {

  #if DEBUG==true
    Serial.println("Starting PCF8574s for LEDs");
  #endif

  pcf8574_av.pinMode(P0, OUTPUT, HIGH);
  pcf8574_av.pinMode(P1, OUTPUT, HIGH);
  pcf8574_av.pinMode(P2, OUTPUT, HIGH);
  pcf8574_av.pinMode(P3, OUTPUT, HIGH);
  pcf8574_av.pinMode(P4, OUTPUT, HIGH);
  pcf8574_av.pinMode(P5, OUTPUT, HIGH);
  pcf8574_av.pinMode(P6, OUTPUT, HIGH);
  pcf8574_av.pinMode(P7, OUTPUT, HIGH);

  #if DEBUG==true
    Serial.print("Init pcf8574 availables...");
  #endif

	if (pcf8574_av.begin()){
    #if DEBUG==true
		  Serial.println("OK");
    #endif
	}else{
    #if DEBUG==true
		  Serial.println("KO");
    #endif
	}

  delay(100);


  pcf8574_fail.pinMode(P0, OUTPUT);
  pcf8574_fail.pinMode(P1, OUTPUT);
  pcf8574_fail.pinMode(P2, OUTPUT);
  pcf8574_fail.pinMode(P3, OUTPUT);
  pcf8574_fail.pinMode(P4, OUTPUT);
  pcf8574_fail.pinMode(P5, OUTPUT);
  pcf8574_fail.pinMode(P6, OUTPUT);
  pcf8574_fail.pinMode(P7, OUTPUT);

  #if DEBUG==true
    Serial.print("Init pcf8574 fails...");
  #endif

	if (pcf8574_fail.begin()){
    #if DEBUG==true
		  Serial.println("OK");
    #endif
	}else{
    #if DEBUG==true
		  Serial.println("KO");
    #endif
	}

  delay(100);


  pcf8574_en.pinMode(P0, OUTPUT);
  pcf8574_en.pinMode(P1, OUTPUT);
  pcf8574_en.pinMode(P2, OUTPUT);
  pcf8574_en.pinMode(P3, OUTPUT);
  pcf8574_en.pinMode(P4, OUTPUT);
  pcf8574_en.pinMode(P5, OUTPUT);
  pcf8574_en.pinMode(P6, OUTPUT);
  pcf8574_en.pinMode(P7, OUTPUT);

  #if DEBUG==true
    Serial.print("Init pcf8574 enables...");
  #endif

	if (pcf8574_en.begin()){
    #if DEBUG==true
		  Serial.println("OK");
    #endif
	}else{
    #if DEBUG==true
		  Serial.println("KO");
    #endif
	}

  delay(100);


  #if DEBUG==true
    Serial.println("Init PCF8574s finished.");
  #endif

}

This run in Setup, also run a scan for i2c devices. This is show by terminal:

Code:
Scanning...
Device found at address 0x38  (RA8875,FT6206,MAX98390)
Device found at address 0x39  (TSL2561, APDS9960)     
Device found at address 0x3B  (unknown chip)
done

Starting PCF8574s for LEDs
Init pcf8574 availables...OK
Init pcf8574 fails...OK
Init pcf8574 enables...OK

But not show "Init PCF8574s finished."...

Library: https://github.com/xreef/PCF8574_library

Any solution?

Regards
 
Status
Not open for further replies.
Back
Top