TinyClr I2C Writes but not Reads

I’m trying to communicate via I2C to this device AT24MAC402 to get a unique MAC address so it can be used on a product. From the documentation, it requires one device address for writing and one device address for reading. The way it operates is that you write the memory address you want on a device address (dummy write) and then read it on a different device address.

I’m creating 2 devices. One for writing and one for reading as specified. I’m able to write to the device, but when I try to read it, it generates a CLR_E_Timeout.

Any ideas are greatly appreciated.

I2cController i2CController = I2cController.FromName(SC20260.I2cBus.I2c3);
            I2cDevice i2CDeviceWriter = i2CController.GetDevice(new I2cConnectionSettings(0xB0, 100000));
            I2cDevice i2CDeviceReader = i2CController.GetDevice(new I2cConnectionSettings(0xB1, 100000));
            //Write to the 
            byte[] bytesToWRite = new byte[2];
            bytesToWRite[0] = 154;

            //Read it
            byte[] bytesToGet = new byte[6];

You are doing it wrong. TinyCLR handles that for you. The address is just the 7 upper bits. The lower bit for read and write is automatically handled by TinyCLR. You should not create 2 devices.

Your address is 0b1011000

1 Like

Oh, that’s right… :man_facepalming: Thanks.

I need more sleep…

1 Like