Created Thu, 11 Aug 2016 14:43:53 +0000 by edringel
Thu, 11 Aug 2016 14:43:53 +0000
Hi, Trying to understand why an i2c sketch doesn't work on a fubarino sd. Before I start really digging and debugging, there seems to be an obvious question. The board literature indicates that there are two i2c channels. Do I need to specify which channel? If so, how? Do I need to modify any of the Wire documents to do so? Thank you.
Ed
Thu, 11 Aug 2016 18:25:46 +0000
The Wire.h library only supports one (the primary) I2C channel. To use the other channel you should port your code to the DTWI library which supports both channels but has a different API.
The primary channel uses pins 1 and 2 (SDA/SCL respectively).
Don't forget (something which many Arduino users don't realise) you need 3.3KΩ pullup (to 3.3V) resistors on both the SDA and SCL lines. The Arduino boards wrongly enable the internal pullups which are completely the wrong value for an I2C bus (typically 10-20x too big).
Thu, 11 Aug 2016 18:52:16 +0000
Thanks. I do have pullup resistors, and I am using pins 1 & 2. Guess I need to do a bit more digging. Thank you.
Ed
Fri, 12 Aug 2016 07:55:10 +0000
Salut,
I looked at the DTWI native code and what wire does. As Matt stated, wire is simply a wrapper around the DTWI library and after some tests it appears to me that whatever I tried I ended up writing the same wrapper in my local code. So I finally decided to modify the wire library and rename all to wire2 for the second bus. I have the lib attached if you want to take a look at it. With that lib I was able to drive a I2C OLED on the second bus.
With wire2, all you have to do is replace all wire statements in the sketch with wire2
Ciao, Mathias