🎁📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 2 Day orders by 11am Monday, December 16 📦❄️📬🎁
0

BBB and I2C Backpack, Use I2C1?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

BBB and I2C Backpack, Use I2C1?

by dpancoe on Tue Nov 26, 2019 7:59 pm

Due to a board layout error, I need to use the i2c character LCD backpack on the I2C1 bus (SCL = P9-17, SDA = P9-18) instead of the default I2C2 bus (SCL = P9-19, SDA = P9-20).

If I use config-pin to make P9-17 & 18 into I2C pins (aware that this is only a temporary solution), I can detect the backpack when I do an i2cdetect -y -r 1, but when I run the test example code, I get a "no device at address 20" error.

What's the best way to get the Adafruit library to talk to the backpack on IC21? I see that the old library allowed the user to set the bus, and I see that the current library defaults to board.SDA and board.SCL, but I didn't find where those values are set.

Thanks,
Don

dpancoe
 
Posts: 17
Joined: Thu Sep 06, 2012 10:28 am

Re: BBB and I2C Backpack, Use I2C1?

by dpancoe on Sun Dec 01, 2019 4:48 pm

Here are two workarounds I found. Both worked for me.

For the first, I modified my code as follows...
Code: Select all | TOGGLE FULL SIZE
from adafruit_blinka.microcontroller.am335x import pin
...
i2c = busio.I2C(pin.I2C1_SCL, pin.I2C1_SDA)  # was (board.SLC, board.SDA)
For the second, I modified beaglebone_black.py as follows, from...
Code: Select all | TOGGLE FULL SIZE
123    SDA = pin.I2C2_SDA  # P9_19
124    SCL = pin.I2C2_SCL  # P9_20
to...
Code: Select all | TOGGLE FULL SIZE
123    SDA1 = pin.I2C1_SDA  # P9_17
124    SCL1 = pin.I2C1_SCL  # P9_18
125    SDA2 = pin.I2C2_SDA  # P9_19
126    SCL2 = pin.I2C2_SCL  # P9_20
then I only had to modify my code as follows...
Code: Select all | TOGGLE FULL SIZE
i2c = busio.I2C(board.SCL1, board.SDA1)  # was (board.SLC, board.SDA)
Don

dpancoe
 
Posts: 17
Joined: Thu Sep 06, 2012 10:28 am

Re: BBB and I2C Backpack, Use I2C1?

by dpancoe on Sun Dec 01, 2019 5:01 pm

As a side note, since I am using the BeagleBone Black Industrial (extended temperature range, but otherwise the same), I had to add the following lines to board.py

Code: Select all | TOGGLE FULL SIZE
elif board_id == ap_board.BEAGLEBONE_BLACK_INDUSTRIAL:
    from adafruit_blinka.board.beaglebone_black import *

dpancoe
 
Posts: 17
Joined: Thu Sep 06, 2012 10:28 am

Re: BBB and I2C Backpack, Use I2C1?

by drewfustini on Sun Dec 01, 2019 9:30 pm

Could you raise a pull request to add the Industrial to Adafruit_Blinka like you did in your local version?

Thanks!

drewfustini
 
Posts: 913
Joined: Sat Dec 26, 2015 1:19 pm

Re: BBB and I2C Backpack, Use I2C1?

by dpancoe on Mon Dec 02, 2019 8:47 pm

Done. Didn't push my other changes since those would create problems with other published code.

Don

dpancoe
 
Posts: 17
Joined: Thu Sep 06, 2012 10:28 am

Please be positive and constructive with your questions and comments.