Tried to communicate with CY8C9540A via I2C.
I could find the device or at least the address of the registers with an I2C Scanner,
but other than that I was not able to communicate with the port expander.
I tried every available I2C bus on Arduino Portenta H7 with Portenta Breakoutboard:
Wire.begin() which should be the same as Breakout.I2C_0.begin()
Wire1.begin() which should be the same as Breakout.I2c_1.begin()
Wire2.begin() which should be the same as Breakout.I2C_2.begin()
I also tried the CY8C95XX library.
Then I also tested the same parameters with an ESP32 which I had laying around.
But I just couldn't run a simple OUTPUT Task on the Expand7Click.
I reviewed every connection several times, and even changed some cables,
but I could communicate with the port expander.
When running the I2C Scanner I couldn't find the EEPROM which was strange as well.
Then I decided to test MCP23017 which I couldn't get to run either on the Portenta h7 Pro with the breakout board.
So I tried running the same code using the Adafruit MCP23XXX library on an ESP32, an ESP8266 and an Arduino UNO which I had laying around.
My Sketch was the blink example which toggles on and of an LED at a given pin every 500ms.
This worked right out of the box for all 3 µC I tested. But the exact same code refused to run on the Portenta,
I tried again every possible combination and variation with the 3 I2C busses as well as an
additional library for the I2C which someone posted in the Arduino forum. It just didn't work. to make sure I didn't damage the MCP23017
I plugged it into the three other µC again which had the same code stored so I just had to power everything up and it just worked.
I also tried a different MCP23017 and again it works on the ESPs and the UNO but not on the Arduino Portenta H7 pro.
Strangely when running the I2C Scanner again, I couldn't find the MCP23017 at 0x20 on either of the three I2C busses,
but I could find the CY8C9540A using the exact same wiring. However, on the ESP32, ESP8266 and the Ardunio UNO I could find the MCP23017 at the I2C address 0x20.
I asked ChatGPT, added PULL_UP resistors to the I2C lanes changed the I2C frequencies and everything I could find out.
It is a bummer that the Pro Series of Arduino is so badly documented and not functioning how it is intended, even more considering the high price Tag.
I wanted to connect the Interrupt Pins of the port expanders to the breakout board, but I did not find any information about the GPIO Pins on the Breakoutboard that support interrupts.
Here is the I2C_Scanner which I used on the Portenta H7:
#include <Arduino.h>
#include <Arduino_PortentaBreakout.h>
#include <Wire.h>
void setup()
{
Wire.begin();
//Wire.setClock(100000); //tried different I2C frequencies as well
Wire1.begin();
Wire2.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
while (!Serial);
Serial.println("Looping...");
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning I2C_0");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
Serial.println("Scanning I2C_1");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire1.beginTransmission(address);
error = Wire1.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
Serial.println("Scanning I2C_2");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire2.beginTransmission(address);
error = Wire2.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}
Two other "problems" I discover are that
A) the 3,3V Pins only output 3,0V
B) Using the Arduino IDE 2.0 and 1.8 it takes like 5 min to upload a simple blink example to the Arduino Portenta, that is why I switched to Platform.io were it only takes about 20 sec.