Which SPI bus,device combination do I use? BBB

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
all2ham
 
Posts: 2
Joined: Sat Jun 27, 2015 3:11 pm

Which SPI bus,device combination do I use? BBB

Post by all2ham »

bbbdacspi copy.jpg
bbbdacspi copy.jpg (920.75 KiB) Viewed 411 times
Hello,

I have a BBB trying to connect to a MCP4922 (http://ww1.microchip.com/downloads/en/D ... 22250A.pdf) over SPI.

I have been trying for several days now and can not get it to output a voltage.

I don't know how to configure the SPI library (in terms of rising/falling edge and high/low clock)

Furthermore, every guide I see is using the command SPI(1,0) or SPI(2,0), whereas I can only use SPI(0,0), otherwise I get

Code: Select all

>>> spi = SPI[1,0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'type' object has no attribute '__getitem__'
Could this be the issue? I have triple checked my wiring to make sure everything is connected correctly.

I also included a picture of the wiring I did.

Any and all help appreciated greatly.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Which SPI bus,device combination do I use? BBB

Post by adafruit_support_mike »

Could you post the code you're using please?

User avatar
all2ham
 
Posts: 2
Joined: Sat Jun 27, 2015 3:11 pm

Re: Which SPI bus,device combination do I use? BBB

Post by all2ham »

adafruit_support_mike wrote:Could you post the code you're using please?
Hi Mike, sorry for the late reply I kind of assumed the thread died. Here is the full code:

Code: Select all

import string
from Adafruit_BBIO.SPI import SPI

# Set up the SPI
dac = SPI(0,0)
dac.mode = 0  # SPI mode 1
dac.bpw = 8


vDes  = 0.8

#set reference voltage
vRef = 3.3

#find percentage of 4096 (due to 12bit) needed
per = int(vDes/vRef*4096)
per = bin(per)[2:]
per = string.zfill(per,12)
part1b = per[:4]
part2 = per[-8:]

#need these 4 bits for the MCP4922 to operate correctly
part1a = bin(0b0011)[2:]
part1a = string.zfill(part1a,4)

part1 = part1a + part1b
part1 = int(part1,2)
part2 = int(part2,2)

#tried all of the writebytes commands, no success
#dac.writebytes([part1,part2])
dac.open(0,0)
#dac.writebytes([0x33,0xE0])
dac.writebytes([0b00111110,0b00001100])
dac.close()

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”