Adafruit_BBIO 16 bit SPI on Beaglebone

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
bumin
 
Posts: 1
Joined: Sun Aug 03, 2014 6:48 pm

Adafruit_BBIO 16 bit SPI on Beaglebone

Post by bumin »

Hello everybody,

I am not sure if this is the correct place to post my problem. I am very new to the
Beaglebone and embedded systems under Linux.

I am currently trying to get a 16bit ADC running via SPI1 on my Beaglebone Black.
My OS is Debian Wheezy with the 3.8.13 kernel. So far I have disabled the HDMI
interface and got the spidev1.0 and spidev1.1 running. (Aside from my actual
problem I am not sure what the last number represents.)

I have shot wired the P9_29 and P9_30 pins to test the communication. My program is written
in Python 2.7 and I am using the Adafruit_BBIO modul to control the SPI
(https://github.com/adafruit/adafruit-be ... -io-python).

When trying to send and receive one 16-bit word with the following code:

Code: Select all

import Adafruit_BBIO.SPI as SPI
print "Testing SPI: P9_29 and P9_30 need to be short wired"
spi = SPI.SPI()
spi.open(1,0)
spi.bpw = 16
print "Word length is : " + str(spi.bpw)
resp = spi.xfer([0x1234]) # transfer one word of two bytes length
print "Sending 0x1234 via xfer - receiving: " + str(resp)
spi.close() #close the port before exit
I only receive 8 bit, being the 8 LBS "34". The same goes for the xfer2 method.

Does somebody have any experience with this type of problem, or am I missing something obvious?
Any help would be appreciated!

Best Regards,
Bumin

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

Re: Adafruit_BBIO 16 bit SPI on Beaglebone

Post by adafruit_support_mike »

Try calling 'spi.set_bpw()' rather than trying to set it explicitly. That method contains some magic beyond straight value assignment.

User avatar
mm_abby
 
Posts: 2
Joined: Tue Sep 23, 2014 8:46 pm

Re: Adafruit_BBIO 16 bit SPI on Beaglebone

Post by mm_abby »

Hi,

I was able to initialize and set the bpw using Bumins method of directly setting the variable, but was not able to call it using spi.set_bpw(10).
I get the following error :
AttributeError: 'SPI' object has no attribute 'set_bpw'



please let me know if you can help.
Thank you!

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

Re: Adafruit_BBIO 16 bit SPI on Beaglebone

Post by adafruit_support_mike »

Could you post the code you're using please (between CODE tags)?

User avatar
mm_abby
 
Posts: 2
Joined: Tue Sep 23, 2014 8:46 pm

Re: Adafruit_BBIO 16 bit SPI on Beaglebone

Post by mm_abby »

Hi,
It only works when I call the bpw (and all other attributes) explicitly
Below is what it looks like when i run it inside of a python shell:

Code: Select all

>>> from Adafruit_BBIO.SPI import SPI
>>> spi = SPI(0,0)
>>> spi.set_bpw(10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'SPI' object has no attribute 'set_bpw'
>>> spi.bpw=10
Thank you!

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

Re: Adafruit_BBIO 16 bit SPI on Beaglebone

Post by adafruit_support_mike »

I know there have been some changes to the BBIO library, but I don't know the details. Let me check with the folks who are responsible for that code.

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

Return to “Beagle Bone & Adafruit Beagle Bone products”