eejake52
Posts: 8
Joined: Wed Jul 29, 2015 10:32 pm

Need both I2C0 and I2C1

Fri Aug 14, 2015 8:52 pm

I am building an audio distribution system that uses a Raspberry Pi to control 6 DACs using I2C. The DAC is a MAX9850, but it is only possible to configure each DAC to one of three addresses. So, on bus I2C1, I have the three DACS, each with a unique address, and all is fine. But now I want to put 3 more DACs on bus I2C0. This where I have a problem.

I have two identical Raspberry Pi 2 Model B. One is the target/production device and the other is for testing.

On the target Pi, I am using the Volumio 1.55 distribution, which is based on Raspbian 3.18.5-v7+. I am unable to access I2C0 on this device. I have configured it as follows:
/boot/config.txt

Code: Select all

dtparam=i2c_vc=on
/etc/modules

Code: Select all

i2c-dev
When I try this:
sudo i2cdetect -y 0
I can see activity on the SCL and SDA lines on the oscilloscope and they look fine. In fact, I can see my devices attempting to respond (holding bit 9 of SDA low), but they don't show up on the output.
I saw in another thread (see last two posts of viewtopic.php?f=44&t=102130), to try and change the MODE of GPIO 28 and 29, using PIGPIOD; and I was able to change the mode (thanks Joan), but after the change, there was no longer any signal on the scope, and of course still no output on I2CDETECT.

Meanwhile, On the testing Pi, I tried running Raspbian 3.18.11-v7+. I enabled I2C0 and I2C1 and I can see devices on both buses with I2CDETECT and the application works fine. This is promising, but apparently there are differences between the Raspbian versions that make it difficult to apply the same configuration to an earlier version; but here are the snippets anyway:
/boot/config.txt

Code: Select all

dtparam=i2c_arm=on
dtparam=i2c_vc=on
/etc/modules

Code: Select all

i2c-dev
So, the obvious answer is to use the newer version of Raspbian; BUT the creators of Volumio have advised against doing an upgrade (apparently because the kernel has been modified); but if I knew how to just update the kernel, I would try it on my testing Pi.

I'm stuck now and can't see a path forward. I welcome any suggestions.

Jake

User avatar
mikronauts
Posts: 2734
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Need both I2C0 and I2C1

Fri Aug 14, 2015 9:04 pm

Use an SPI bus multiplexer, see Adafruit
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7708
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Need both I2C0 and I2C1

Fri Aug 14, 2015 9:55 pm

The output from "sudo raspi-gpio get" (you may need to "sudo apt-get install raspi-gpio" first) would be useful, as would the Hardware and Revision lines from "cat /proc/cpuinfo"
IIRC the last investigation resulted in a change to the GPU side dt-blob due to an error on one particular board revision, so that could be replicated by generating your own and dropping it in as /boot/dtblob.bin. Seeing in difference in Revision would be useful first.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

eejake52
Posts: 8
Joined: Wed Jul 29, 2015 10:32 pm

Re: Need both I2C0 and I2C1

Sat Aug 15, 2015 4:27 pm

Info requested by 6by9

Code: Select all

[email protected]:~$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 5 (v7l)
BogoMIPS        : 57.60
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5
<snip ... processor 1/2/3 identical>
Hardware        : BCM2709
Revision        : a21041
Serial          : 0000000045f6bf77
I couldn't find any programs nor packages called raspi-gpio, nor any variation thereof. Please clarify which one is applicable.

Thanks for looking,
Jake

eejake52
Posts: 8
Joined: Wed Jul 29, 2015 10:32 pm

Re: Need both I2C0 and I2C1

Sat Aug 15, 2015 4:29 pm

mikronauts wrote:Use an SPI bus multiplexer, see Adafruit
I understand the concept, but I couldn't find any such product at Adafruit.
As a backup plan, I can just use two Raspberry Pi; although it does seem a waste since they both have two I2C buses.

Jake

User avatar
joan
Posts: 14560
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Need both I2C0 and I2C1

Sat Aug 15, 2015 4:35 pm

Could you confirm you have the Pi B with the 26 pin header plus separate (unpopulated) 8 pin header?

I have one of those and I2C does work on both buses.

raspi-gpio refers to https://github.com/RPi-Distro/raspi-gpio

I don't think it'll tell you anything you don't already know.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7708
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Need both I2C0 and I2C1

Sat Aug 15, 2015 4:51 pm

On Raspbian:

Code: Select all

sudo apt-get update
sudo apt-get install raspi-gpio
Where are you connecting to for I2C-0? Pins 27 & 28 on the 40way (BCM GPIOs 0 & 1)? Have you added appropriate pull ups as there aren't any fitted as standard?

Others have used http://dsscircuits.com/sale/product/dssc0107 as an I2C mux - a search on the forum for dsscircuits throws up lots of hits.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
joan
Posts: 14560
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Need both I2C0 and I2C1

Sat Aug 15, 2015 5:44 pm

Okay, I misread your Pi version.

On the Pi2 all you need to do is add

dtparam=i2c_arm=on
dtparam=i2c_vc=on

to /boot/config.txt

and

i2c-dev

to /etc/modules

As 6by9 says you also need to add pull-ups to 3V3 on the SDA and SCL lines.

I've just tried this with an OLED connected to gpios 0/1 (pins 27/28) with 2k2 resistors to 3V3 on a Pi2.

It works fine.

User avatar
mikronauts
Posts: 2734
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Need both I2C0 and I2C1

Sat Aug 15, 2015 5:55 pm

Try http://dsscircuits.com/sale/product/dssc0107

I guess Adafruit no longer sells them? Or never sold them, in case my memory was bad.
eejake52 wrote:
mikronauts wrote:Use an SPI bus multiplexer, see Adafruit
I understand the concept, but I couldn't find any such product at Adafruit.
As a backup plan, I can just use two Raspberry Pi; although it does seem a waste since they both have two I2C buses.

Jake
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

eejake52
Posts: 8
Joined: Wed Jul 29, 2015 10:32 pm

Re: Need both I2C0 and I2C1

Sat Aug 15, 2015 8:30 pm

Short version: it's all working now.

Slightly longer and embarrassing version: the answer was right in front of me in the other thread mentioned above. I made a mistake when I tried the suggested solution, and mistakenly concluded that it didn't apply to me. The fix is:

in a root shell or rc.local:

Code: Select all

    echo 28 > /sys/class/gpio/export
    echo 29 > /sys/class/gpio/export
    echo in > /sys/class/gpio/gpio28/direction
    echo in > /sys/class/gpio/gpio29/direction
Thanks for all your help and suggestions.
Jake

Return to “Interfacing (DSI, CSI, I2C, etc.)”