Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more.
0

SPI between two beaglebone Black
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

SPI between two beaglebone Black

by BobUS on Tue Jun 21, 2016 4:07 pm

Hello everybody,

I try to have a transfer data between two beaglebone using SPI.
Here is my (simple) program to write in Python:
Code: Select all | TOGGLE FULL SIZE
from bbio import *
import time

cs=0

SPI0.begin()

SPI0.setMaxFrequency(cs, 1000000)
SPI0.setBitsPerWord(cs, 8)
SPI0.setClockMode(cs, 1)
SPI0.setCSActiveLow(cs)
SPI0.setMSBFirst(cs)


try:
  while True:
    SPI0.write(0, [1])
    time.sleep(0.01)
except KeyboardInterrupt:
 SPI0.close()


and to read data:

Code: Select all | TOGGLE FULL SIZE
from bbio import *
import time

cs=0

SPI0.begin()

SPI0.setMaxFrequency(cs, 1000000)
SPI0.setBitsPerWord(cs, 8)
SPI0.setClockMode(cs, 1)
SPI0.setCSActiveLow(cs)
SPI0.setMSBFirst(cs)

# Read a single 8-bit word from the device:
data = SPI0.read(cs, 1)
print "word received: {:x}".format(data[0])

SPI0.close()


The problem is that I always receive FF (255) and the master seems to send no data.
I followed this schematics (above): Image

Have you any idea to solve my problem?

BobUS
 
Posts: 3
Joined: Tue Jun 21, 2016 3:54 pm

Re: SPI between two beaglebone Black

by drewfustini on Wed Jun 22, 2016 12:54 am

It looks like you are using the PyBBIO library:
https://github.com/graycatlabs/PyBBIO

Have you tried raising an issue there?

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

Re: SPI between two beaglebone Black

by BobUS on Wed Jun 22, 2016 11:55 am

In fact, I hoped that someone could help me here (even by using the Adafruit library). But I see that BBB is consider as a master and master cannot talk each other in SPI (I2C too).

BobUS
 
Posts: 3
Joined: Tue Jun 21, 2016 3:54 pm

Re: SPI between two beaglebone Black

by drewfustini on Wed Jun 22, 2016 4:05 pm

This current Google Summer of Code project for BeagleBoard.org may be of interest to you:

SPI slave driver implementation

Student: Patryk Mężydło
Code: https://github.com/pmezydlo/SPI_slave_d ... ementation
Wiki: https://github.com/pmezydlo/SPI_slave_d ... ation/wiki

SPI slave driver implementation. The task is to create a driver controlling SPI hardware controller in slave mode, and to ensure optimal performance through the use of DMA and interrupt. Creating an easy to implement realization of SPI slave would definitely help the BeagleBone community members to write applications based on SPI much more easily.

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

Re: SPI between two beaglebone Black

by BobUS on Thu Jun 23, 2016 12:07 pm

OK, thank you. I will see that.

BobUS
 
Posts: 3
Joined: Tue Jun 21, 2016 3:54 pm

Please be positive and constructive with your questions and comments.