Communicate Beaglebone Black and Arduino via SPI

Beaglebone is getting very popular day by day. With this cheap single board computer you can create such amazing things. Probably this things need communicate other things to progress something. In the video I just simply show the required diagrams and connections. You will learn how to communicate BBB and Arduino via SPI. Therefore, I do not write much about SPI, you can find for more in my other tutorials.

First, in BBB you need to activate the SPI device. To do that, you need to create a dts file, after then compile. But If you use latest debian image for you BBB , it is not needed these steps. To understand the situation

above, In firmware file, dtbo (device tree blob object) file is available. To activate the SPI the following command line is copied in the uEnv.txt ( under boot file for mine ) then reboot the BBB, so SPI is ready for use.

also you should see under /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups using any editor (like nano )

Second, lets see how the code looks like for BBB. For this tutorial C++ is used. You need gcc compiler, probably you already have. First code send only data with write command , second code is sent data also wait for the coming data at the same time. As it is known for the SPI interface that at the same time you can send data and get data.

Third, we make ready Arduino pro mini for SPI. Unlike BBB we do not have to do nothing. Just connections as in the video. I use here Arduino pro mini, because beaglebone is working with 3.3v , for compability , Arduino pro mini 3.3v is good for me. You can, also make you arduino uno working with 3.3v but you need to change on board physical things. It takes time. there is another trick to communicate with different voltage levels, using voltage level converters.If you as how arduino pro mini program, you can use arduino uno board. to do that just remove the Microcontroller on the board then choose arduino pro mini and specify it is 3.3v in arduino ide. It is simple. Then make connections like in the video, before the send the code press the reset button on the arduino pro mini, then send the code, when tx or rx pin is blinking, release the reset button, so after you will see pro mini will be programmed.

The code is here, I search much in the internet about spı for arduino. There are good examples, therefore I could not find what I need. Some use libraries some use not. Some make different algorithms that I do not understand. In such a communications, I mean, here BBB is master, arduino is slave. Arduino waits data and when data came it writes back to the BBB, interrupts are the painless solutions. That is why I used interrupt service routine in the code. For configuration I read a little bit datasheet of atmega328p to use special function registers. You can see in the code.

when arduino takes the byte from MOSI line it writes automatically to the MISO line. I hope this tutorial gives you some idea. Thanks.. 30/04/2016