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: 57106
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: 57106
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: 57106
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: 57106
Joined: Thu Feb 11, 2010 2:51 pm

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

by RocketScientist on Mon Mar 25, 2019 3:56 pm

I am finding a similar problem. I have an application that was designed (and works) with a Feather M0 as I2C master - essentially a data logging and telemetry app using a variety of sensors, mostly I2C based - a STEM project for student satellites for rockets and HABs. The sensors are primarily on daughterboards from third parties, some AdaFruit, some SparkFun, some from Tindie vendors. The core sensors and core code worked on the Feather M0.

I am porting to the ItsyBitsy M4 as a size reduction, and finding problems. I have checked continuity of wires, pull-ups on the I2C bus, changing I2C clock speed.

My startup code uses an I2C scanner to check the presence of the sensors. I have checked both each sensor individually and in some combinations. And I am finding four new behaviors on the M4::

1. Phantom detection of low addressed (<0x10) devices - the number varies depending on the sensor attached ranging from zero to ~4.
2. Undetected devices - one daughterboard has two I2C sensors - a CS811 gas sensor and BME280 pressure sensor - the BME280 is always detected (at the correct I2C address), the CS811 is never detected. A similar daughterboard that has an LSM9DS1 IMU and an MS5611 pressure sensor always detects all three addressed devices at the correct addresses.
3. Failure to access - even when sensors detected, any attempt to open the devices for access results in failure.
4. Crashes program - it appears that when an existing device at a known address is accessed - the M4 program crashes and halts (no evidence yet of burning).

Two new sensors from SparkFun (an I2C GPS and an IR imaging array) are never detected but both stimulate the phantom detection of a device with address 0x01.

Thoughts? Help?

Ken

RocketScientist
 
Posts: 61
Joined: Wed Jan 11, 2017 11:43 pm

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

by bcochran1 on Mon Mar 25, 2019 5:00 pm

RocketScientist wrote:I am finding a similar problem. I have an application that was designed (and works) with a Feather M0 as I2C master - essentially a data logging and telemetry app using a variety of sensors, mostly I2C based - a STEM project for student satellites for rockets and HABs. The sensors are primarily on daughterboards from third parties, some AdaFruit, some SparkFun, some from Tindie vendors. The core sensors and core code worked on the Feather M0.

I am porting to the ItsyBitsy M4 as a size reduction, and finding problems. I have checked continuity of wires, pull-ups on the I2C bus, changing I2C clock speed.

My startup code uses an I2C scanner to check the presence of the sensors. I have checked both each sensor individually and in some combinations. And I am finding four new behaviors on the M4::

1. Phantom detection of low addressed (<0x10) devices - the number varies depending on the sensor attached ranging from zero to ~4.
2. Undetected devices - one daughterboard has two I2C sensors - a CS811 gas sensor and BME280 pressure sensor - the BME280 is always detected (at the correct I2C address), the CS811 is never detected. A similar daughterboard that has an LSM9DS1 IMU and an MS5611 pressure sensor always detects all three addressed devices at the correct addresses.
3. Failure to access - even when sensors detected, any attempt to open the devices for access results in failure.
4. Crashes program - it appears that when an existing device at a known address is accessed - the M4 program crashes and halts (no evidence yet of burning).

Two new sensors from SparkFun (an I2C GPS and an IR imaging array) are never detected but both stimulate the phantom detection of a device with address 0x01.

Thoughts? Help?

Ken


Hi!

I wonder if you could kindly post your code including the I2C scanning code and photos of your devices and wiring. What version(s) of the bootloader do you have on your devices? Are you using CircuitPython or Arduino?

I have both the ItsyBitsy M0 Express and the ItsyBitsy M4 Express. I wonder if I can reproduce your issues. Where did you get the sensors from? Of course it will take time for me to purchase the sensors that your app cannot detect. So really, no promises from me at all, and no guarantees from me either, but I have much curiosity.

Thanks so much

Bob

bcochran1
 
Posts: 349
Joined: Mon Jan 21, 2013 10:46 pm

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

by RocketScientist on Mon Mar 25, 2019 6:22 pm

Love to have other looks at the problem. The project and code base are bigger than is appropriate to post here.

Here is a link to the Feather M0 project description including links to all of the sensors for that version. https://www.dropbox.com/s/jvfnyekktan3yg0/2018%20S4%20Technical%20Overview.pdf?dl=0

The key I2C sensor is this one https://www.tindie.com/products/onehorse/air-quality-sensors/ for eCO2, TVOC and pressure/humidity/temperature.

If that sensor works ... I think the rest will follow. The fact that I am not recognizing those simple sensors is puzzling (and frustrating).

The current code base (semi adapted to the M4 but should work for the M0 as long as only I2C sensors are configured) is here https://www.dropbox.com/s/nnn0iaoohv9zsd2/PQ_Payload_10.ino?dl=0.

Thanks in advance for help ... but look forward to Adafruit tech support.

RocketScientist
 
Posts: 61
Joined: Wed Jan 11, 2017 11:43 pm

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

by MizeSoundGuy on Tue Apr 02, 2019 1:02 am

Just tonight I started moving a little program that uses I2C from a Trinket M0 to an Itsy Bitsy M4 Express. I have a single MCP4728 quad DAC and generate 4 signals with it. It's not a lot of code because I read the values I am outputting (4 60Hz sine waves) from a table and it works "pretty well" on the TM0 but that board has no crystal so getting the 60Hz right is difficult (for me).

I connected the IBM4E to the DAC with 2 x 2.2k pullups to 3.3V (from the board), changed the board and compiled/uploaded the I2C scanner and it found my DAC. Then I uploaded a file that had worked on the TM0 and sure enough, it works on the IBM4E. Since I am using a different reference voltage than on the TM0, (3.3 instead of 5), my signals are lower but they are still being output by the DAC.

My program does not read from I2C, it only writes to it. And I know next to nothing about the inner workings of I2C except that I can tinker with the clock to get the 60Hz.

One data point to say that I2C on the IBM4E works at at least a little bit.

MizeSoundGuy
 
Posts: 25
Joined: Sun Apr 05, 2015 4:09 pm

Please be positive and constructive with your questions and comments.