9 years, 7 months ago.

GR-PEACH I2C not completely working

Hello GR-PEACH team,

I am reporting an issue with the GR-PEACH regarding I2C.

I2C works as long as you use the complex commands where a character buffer is required.

#define TESTADDRESS     0xd0    //typical for RTCs like DS1307, DS3232 ot M41T11
#define POINTER         0       //set up internal pointer to the i2c slave device's data

    data[0] = POINTER;
    wr_ack_ok = i2c.write(TESTADDRESS, &data[0], 1, true);
    rd_ack_ok = i2c.read((TESTADDRESS | 1), &data[0], 7, true);

However, using low level I2C commands (code below) does not work. In fact, I2C example above will stop working if the code below is executed. A power cycle is required in order for the above example to work again.

    char reg0, reg1, reg2 = 0;
    i2c.start();
    wr_ack_ok = i2c.write(TESTADDRESS);
    i2c.write(POINTER);
    i2c.stop();
    i2c.start();
    rd_ack_ok = i2c.write(TESTADDRESS | 1);
    reg0 = i2c.read(true);
    reg1 = i2c.read(true);
    reg2 = i2c.read(false);
    i2c.stop();

Regards,

...kevin

Be the first to answer this question.