0

Itsy Bitsy M4 I2C Not Working (But Works Fine on M0)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Itsy Bitsy M4 I2C Not Working (But Works Fine on M0)

by rlpepe on Wed Feb 20, 2019 1:21 am

I have an Itsy Bitsy M0 running software that uses i2c -- no problems. Note that I'm using the Arduino IDE with the Wire library. Regardless of what the documentation says, there is definitely something pulling SDA and SCL up to 3v3. The same software, however, will not work on the Itsy Bitsy M4. I put an oscilloscope on the bus and see that the SCL line is being pulled up to 3v3, but I'm not seeing anything the clock drive to 0v. I put an i2c scanner sketch on the Itsy Bitsy M4 and it detects all four of my i2c devices... it just won't talk to them. I added external 4.7k pull-up resistors to 3v3 on SDA and SCL just in case, but this did not correct the issue. I also tried explicitly setting wire.setClock(100000), i.e., 1 kHz, but this did not resolve the issue either. Is there something else going on with the M4 that I'm missing? Why would it detect all of my devices, but hang as soon as I try to read registers from my device? Why does the clock signal not pull down to 0v? Again, this is the exact same software and setup -- works fine on the ItsyBitsy M0, but hangs on the ItsyBitsy M4 when it tries to read registers off a slave device on the i2c bus. Help would be appreciated!

rlpepe
 
Posts: 2
Joined: Wed Feb 20, 2019 1:09 am

Re: Itsy Bitsy M4 I2C Not Working (But Works Fine on M0)

by adafruit_support_mike on Fri Feb 22, 2019 4:09 am

If you watch the SDA and SCL signals on the oscilloscope while the M4 is running the I2C scanner, do you see a signal on SCL?

adafruit_support_mike
 
Posts: 55967
Joined: Thu Feb 11, 2010 2:51 pm

Re: Itsy Bitsy M4 I2C Not Working (But Works Fine on M0)

by rlpepe on Sat Feb 23, 2019 2:48 pm

Thanks for the suggestion. Yes, I can see the clock and data lines active when running the I2C scanner. The I2C scanner is very simple. All it does is call Wire.beginTransmission(addr) and result = Wire.endTransmission() for the range of addr=1:126. If reslt==0, it reports a device found at that address. If result==4, it reports an error at that address. Apparently all devices on the i2c bus are acknowledging the address.

Given this, it appears that the problem is reading and writing registers. There are timeouts in the software (e.g., don't call Wire.read() if Wire.available() is less than bytes requested after <n> millseconds), but those aren't being triggered which makes me believe the Wire library is hanging on Wire.write(addr) or on Wire.requestFrom(addr,size). I added 50 microsecond delays between the endTransmission() call to set the read register and the Wire.requestFrom(addr,size) call to read back the register data. This did not resolve the problem. I also set the i2c clock to 10 kHz without resolution to the problem.

I'm still unsure why this is a problem on the ItsyBitsy M4, but is not a problem on the M0 version.

rlpepe
 
Posts: 2
Joined: Wed Feb 20, 2019 1:09 am

Re: Itsy Bitsy M4 I2C Not Working (But Works Fine on M0)

by adafruit_support_mike on Tue Feb 26, 2019 6:19 am

Hmm.. Wire.endTransmission() should only return 0 if SDA is held low after the microcontroller releases it. If no device answers for a given I2C address, it should return the value 2.

Do you see SDA being held low during the 9th tick of SCL after an address is transmitted?

adafruit_support_mike
 
Posts: 55967
Joined: Thu Feb 11, 2010 2:51 pm

Re: Itsy Bitsy M4 I2C Not Working (But Works Fine on M0)

by dbj1906 on Fri Mar 15, 2019 12:59 am

I am having the same problem; my I2C code works on a Trinket M0, but not an ItsyBitsy M4. Wanted to see if there were any known defects/issues.

dbj1906
 
Posts: 13
Joined: Sun Apr 09, 2017 10:30 am

Re: Itsy Bitsy M4 I2C Not Working (But Works Fine on M0)

by adafruit_support_mike on Fri Mar 15, 2019 2:44 am

Try adding external pull-ups on SDA and SCL.

adafruit_support_mike
 
Posts: 55967
Joined: Thu Feb 11, 2010 2:51 pm

Re: Itsy Bitsy M4 I2C Not Working (But Works Fine on M0)

by dbj1906 on Fri Mar 15, 2019 10:01 am

I have tried using a pair of 10K resistors and a pair of 4.7K resistors (to 3.3V). Neither option works. M4 is being set-up in "slave" mode.

dbj1906
 
Posts: 13
Joined: Sun Apr 09, 2017 10:30 am

Re: Itsy Bitsy M4 I2C Not Working (But Works Fine on M0)

by adafruit_support_mike on Sat Mar 16, 2019 12:48 am

Ah.. I don't know how well the SAMD51 Wire library supports slave mode. The chip is still new, and it's a complex device.

As a sanity check, try setting the ItsyBitsy up as an I2C master and see if it works that way. At least that will verify the hardware.

adafruit_support_mike
 
Posts: 55967
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.