I2C not working with SDA1 and SCL1 in an Arduino Due

Hi all,

I am working with an Arduino Due, trying to communicate with some slaves using I2C protocol. In the same shield I have sensors that I read and control using the SDA and SCL pins (20 and 21) using instructions like Wire.xxx(). They work fine.

However, when I try to do the same with SDA1 and SCL1 pins I do not manage to make it work (I know that these pins don't have pullup resistors). I am using a logic analyser to see what is going on at the output pins of my Due (only the due, no shield).

When I use instructions with Wire.xxx(), I manage to see that the Due is sending data to the output. However, when I replace the Wire.xxx() with Wire1.xxx, I don't see anything at the output of SCL1 and SDA1 pins. Below the example function:

uint8_t read_FPGA(uint8_t FPGA_reg_add)
{
  uint8_t FPGA_received;

  Wire1.setClock(50000L);  // Setting clock frequency
  Wire1.beginTransmission(FPGA_ADDRESS);
  Wire1.write(FPGA_reg_add);

  uint8_t err = Wire1.endTransmission(false);
  if (err == 0)
  {
    Wire1.requestFrom(FPGA_ADDRESS, 1);

    while (Wire1.available())
    {
      FPGA_received = Wire1.read();
    }
    Wire1.endTransmission(true); // true
  }
  else
  {
    switch(err)
    {
      case 1: FPGA_received = 0xE1; break;
      case 2: FPGA_received = 0xE2; break;
      case 3: FPGA_received = 0xE3; break;
      case 4: FPGA_received = 0xE4; break;
      default : FPGA_received = 0xE5; break;
    }
  }
  err = 0;

  return FPGA_received;
}

I have seen several posts about similar issues, but they are dated from 2014. As I am using Arduino IDE 1.6.5, I do not think that the same library issues apply to me as I might have the updated versions.

Do you know if this is a known issue? Any suggestion about what can be done?

Thanks!

Hi again,

Last days I've been busy, but today I've been able to work on this issue again. One thing that was bothering me was the fact that the pins SDA1 and SCL1 may just be broken (who knows, this Due is not new and I have used it in other projects).

To test that, I just copied and pasted the function that I sent in the previous message and modified it a little bit to convert it into a standalone sketch. Below the result.

#include "Wire.h"

#define FPGA_ADDRESS 0x30

uint8_t FPGA_reg_add;
uint8_t FPGA_received;

void setup() 
{
  Serial.begin(9600);
  Wire.begin();
  Wire.setClock(50000L);  // Setting clock frequency

}

void loop() 
{
  
  Wire.beginTransmission(FPGA_ADDRESS);
  Wire.write(FPGA_reg_add);

  uint8_t err = Wire.endTransmission(false);
  if (err == 0)
  {
    Wire.requestFrom(FPGA_ADDRESS, 1);

    while (Wire.available())
    {
      FPGA_received = Wire.read();
    }
    Wire.endTransmission(true); // true
  }
  else
  {
    switch(err)
    {
      case 1: FPGA_received = 0xE1; break;
      case 2: FPGA_received = 0xE2; break;
      case 3: FPGA_received = 0xE3; break;
      case 4: FPGA_received = 0xE4; break;
      default : FPGA_received = 0xE5; break;
    }
    Serial.println(FPGA_received);
  }
  err = 0;

}

The sketch works fine for a Due using the SDA and SCL ports (Wire): With a logic analyser I can see how the Due is sending the slave address.

However, when I replace all the Wire.xxx and put Wire1.xxx, I still see nothing on SDA1 and SCL1. And I see the same behaviour using a second Due board.

Does anybody have an idea of what is going on here?

Thanks in advanced!

Just FYI, my Due works fine with Wire1. I use a logic level converter for devices using 5v, and it has a 10K resistor pullups on both lines.

Hi SurferTim,

Thank you for your reply, as it made be think about something I didn't take into account.

When I described my problem I said that I was trying the I2C using only the Arduino Due board connected to the logic analyser. As a consequence, I have no pullup resistors on SDA1 and SCL1 (which I knew).

I tried to perform the very same test but with a small difference: I took a couple of 10k ohm resistors and connected them to SDA1 and SCL1 as pullups. Now, the I2C for these pins works, it sends data. So it seems that something prevented the arduino to make the I2C work in those lines unless pullups where present before. I wonder where in the Wire library is that implemented.

I couldn't find this issue before when using the shield because I wanted these pullup resistors to be the pin pullups of an FPGA connected to those nodes. However, the Arduino programs the FPGA supply LDO using I2C, and as the FPGA pins didn't show the pullups in those lines I could not program the LDO that powers up the FPGA. A never ending cycle.

Now, just for curiosity, I will try to see what prevented the I2C to work without pullups!

Thank you very much for your help!

Struggling with this one. No matter what pull-up I try I don't get a Clk signal on SCL. I suspect a mess with libs since I use Visual Micro IDE. Gonna give a try with Arduino IDE in the next days. In the meanwhile, any suggestion?