An archive of as of Saturday January 26, 2019.

I2C Not Transmitting


Having trouble writing data via I2C.

I thought maybe the problem was with the PCA9956B LED driver we're evaluating but just to be sure, I scoped the SDA and SCL pins and they never go low for a start condition.

i2C0 <- I2C(0);
i2C0.write8(1, 0); -- Halts here with error: %%Runtime error [I2C write error]

I'm using 2.2Kohm pullups on both lines and the documentation looks like instantiating I2C overrides the GPIO use of the port.

Please advise.


An I2C write error is almost always because the device did not ACK the address byte on the I2C bus. This can be for a number of reasons - using the wrong device address, a wiring or pull-up problem, or a problem with the device itself. You can use the code below to scan all addresses on the bus for your device:

i2c <- I2C(0); 
for (local i = 1; i < 128; i++) {
    try {
        i2c.write8(1, 0);
        print("found i2c at " + i + "\n");
    catch(err) {}

SOLVED: The issue was that the PCA9956B device's RESET input wasn't pulled high enough. There must be an issue with the die itself or the datasheet since the spec states to pull it high with <100k ohm. I used 10k and the RESET voltage pin was only at 1.2V. Shunting the pin to VDD took it out of reset. Will need to check with NXP Semi on this one.

Thanks for your quick response Scott!