Strange I2C Problem with SC20260

I am trying to write a driver for the MikroE Proximity 11 Click and ran into a bit of a roadblock initializing the RPR-0521RS IC on the Proximity 11 Click.

Using a SC20260 based board (FezPortal and SC20260 Dev Board) I cannot get the RPR-0521RS IC to respond to I2c commands on the I2cBus.I2c1 and returns all zeros on either board.

However, it works just fine on the other I2c busses (I2c2 and I2c3).

I accidentally stumbled across a solution by adding in an extra zero in the I2cConnectionSettings by setting the bus speed to 4_000_000 and that worked and I was able to read a few known registers and verify the register contents. Running the same code at 400_000 does not work.

I tried the code on the SC20100 Dev board an it initializes at 400_000 just fine.

So I am stumped at this point and can only conclude the differences between I2c1 and I2c2 and three is that I2c1 has pull up resistors whereas I2c2 and I2c3 do not. I have not checked the schematic for the SC20100 DEV board to determine if it has the pull-up resistors or not.

I am running the latest firmware and using a Revision 3 SC20260 Dev Board.

Here is the code I am using to demonstrate the problem I am encountering.

    internal class Program
    {
        private static void Main()
        {
            // This initialization works with the I2cBus Speed set to 2_850_000.
            //I2cDevice _sensor = I2cController.FromName(GHIElectronics.TinyCLR.Pins.SC20260.I2cBus.I2c1).GetDevice(new I2cConnectionSettings(0x38, 2_850_000));

            // This does not work with the I2cBus Speed set to 400_000.
            I2cDevice _sensor = I2cController.FromName(GHIElectronics.TinyCLR.Pins.SC20260.I2cBus.I2c1).GetDevice(new I2cConnectionSettings(0x38, 400_000));

            Thread.Sleep(2); // Per Datasheet, need 2ms before accessing the RPR-0521RS.

            Byte[] registerData = new Byte[1];

            _sensor.WriteRead(new Byte[] {0x42}, registerData);
            Debug.WriteLine($"Register 0x42 is 0x{registerData[0]:x2} and should be 0x02");

            _sensor.WriteRead(new Byte[] {0x43}, registerData);
            Debug.WriteLine($"Register 0x43 is 0x{registerData[0]:x2} and should be 0x01");

            _sensor.WriteRead(new Byte[] {0x4b}, registerData);
            Debug.WriteLine($"Register 0x4b is 0x{registerData[0]:x2} and should be 0xFF");
        }

The CLICK 11 has onboard pullups and so does the Fez Portal on I2C1 so that is likely why it fails to work as expected but works on I2C2 and I2C3. You’ll probably find that the touch fails to work too as that is also on I2C1?

@Dave_McLaughlin. You are correct regarding the pullups. However, if I set the I2cConnectionSettings to 4 MHZ (actually anything above 2.85 MHz) the Proximity 11 Click works perfectly fine.

In fact, all of MikroE I2c based click boards have 4.7k ohm pullups on the SDA and SCL lines and these work just fine.

I don’t know how the clock speed is handled internally by TinyCLR, but I would assume that it would clip anything above 400KHz. But it appears not to be the case.

I am currently using an SCM20260N with a 4.3" on a custom board and using I2C1 to talk to an IMU and it works with the 400_000 Khz setting. This is similar hardware to the Fez Portal. I had to remove the pullup resistors on the IMU module to get it to work. Very strange that you have to set 4 MHz.

Do you have a scope to peek at the clock and verify frequency?

No, I do not but can borrow one in a few days.

probably setting 4MHz, this overflow and only few low bits are selected then work. I don’t think there will be 4MHz on scop.

Pullup resistors or not, this doesn’t explain why it works using the SD20100 Dev Board and not on the SC20260 Dev Board or on the Fez Portal. The firmware for both is the same so it has to be hardware related.

I have finally found the problem with the Proximity 11 Click. It has the same I2C Address as the Capacitive Touch Screen on the SC20260 Dev Board. Once I removed the display it works just fine.

GHI probably should have used another I2C bus rather than share the bus between the MikroE sockets and the touch controller.

2 Likes

maybe

Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout

can resolve your situation

This is similar hardware to the Fez Portal. I had to remove the pullup resistors on the IMU module to get it to work. Very strange that you have to set 4 MHz.