I2C with Debian 8.7 and universal cape?

204 views
Skip to first unread message

mark whitney

unread,
Jun 18, 2017, 12:51:44 AM6/18/17
to BeagleBoard
Hello,

I'm trying to work through the I2C examples in the Molloy book.  But I'm using a Honeywell HMC6352 compass since I had one lying around.  It can work from 2.7V to 5V and operates at a bus frequency of 100KHz.  I verified that it works by hooking it up to a 5V microcontroller.  I can query its registers.  But I haven't had any luck communicating with it on a BeagleBone Black.

I'm using 3.9V pull-up resistors for SDA and SCL.  Here is info about my kernel version, cape slots, and the I2C pins:

debian@beaglebone:~$ uname -a
Linux beaglebone 4.4.54-bone16 #1 Fri Mar 17 04:56:31 UTC 2017 armv7l GNU/Linux
debian@beaglebone:~$ sudo cat $SLOTS
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,cape-universaln
debian@beaglebone:~$ config-pin -i P9.19
Pin is not modifyable: P9_19 i2c2_scl
debian@beaglebone:~$ config-pin -i P9.20
Pin is not modifyable: P9_20 i2c2_sda
debian@beaglebone:~$

It looks like everything is okay.  Am I missing any steps?  I saw some info about adding an I2C overlay.  Is that still necessary with the universal cape?

BTW, I also tried the 4.4.54-ti-r93 kernel without success.

Thanks for any advice.  This noob is stumped.  :-)



Robert Nelson

unread,
Jun 18, 2017, 1:18:23 AM6/18/17
to Beagle Board, markrw...@gmail.com
the i2c port on P9_19/P9_20 is already enabled by default.

Regards,


--
Robert Nelson
https://rcn-ee.com/

mark whitney

unread,
Jun 18, 2017, 11:59:23 AM6/18/17
to BeagleBoard, markrw...@gmail.com
Thank you for the reply.

As a sanity check, I went back to Debian 7.5.  And it just worked without having to do any extra configuration.  See below for a dump of results.  My compass device appears at its default address 0x21.  I sent a command (0x72) to read EEPROM register 0x00 and read back the expected byte (0x42).

With the Debian 8.7 image, I got error messages when I tried the i2cget and i2cset commands.  I also noticed that the i2cdetect -y -r 1 command runs very slowly compared to the Debian 7.5 image, it takes a second or so to print each address entry.

Is there some extra configuration I need to do in Debian 8.7?  Like edit the uEnv.txt file?  Load an overlay?  Or tweak a DTS file?

Thanks!


debian@beaglebone:~$ uname -a
Linux beaglebone 3.8.13-bone50 #1 SMP Tue May 13 13:24:52 UTC 2014 armv7l GNU/Linux
debian@beaglebone:~$ i2cdetect -y -r 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- 21 -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
debian@beaglebone:~$ i2cset -y 1 0x21 0x72 0x00
debian@beaglebone:~$ i2cget -y 1 0x21
0x42

Robert Nelson

unread,
Jun 18, 2017, 12:53:30 PM6/18/17
to Beagle Board, markrw...@gmail.com
Wrong bus..

With 3.8.13 the i2c bus #'s where setup on a first come basis..

With newer kernel's the bus #'s actually corresponds to the i2c bus
#.. In this case: &i2c2..

So use:

i2cdetect -y -r 2

mark whitney

unread,
Jun 18, 2017, 1:53:05 PM6/18/17
to BeagleBoard, markrw...@gmail.com
Derp!  That did the trick.  (See test output below.  It prints the expected default values from my sensor.)

Thanks again.  :-)

debian@beaglebone:~$ uname -a
Linux beaglebone 4.4.54-ti-r93 #1 SMP Fri Mar 17 13:08:22 UTC 2017 armv7l GNU/Linux
debian@beaglebone:~$ gcc compass.c
debian@beaglebone:~$ ./a.out
Starting HMC6352 Compass Test.
EEPROM reg[0x00] = 0x42
EEPROM reg[0x01] = 0x00
EEPROM reg[0x02] = 0x00
EEPROM reg[0x03] = 0x00
EEPROM reg[0x04] = 0x00
EEPROM reg[0x05] = 0x01
EEPROM reg[0x06] = 0x04
EEPROM reg[0x07] = 0x06
EEPROM reg[0x08] = 0x50
Reply all
Reply to author
Forward
0 new messages