Archi
Posts: 2
Joined: Wed Mar 18, 2015 7:43 am

SPI Interface and program with Raspberry Pi 2

Thu Aug 06, 2015 2:11 pm

Good evening, i hope use the SPI serial communication, from RPi 2 and a microprocessor.

In the 40 pin connector there is only one SPI, in the PIN:

19 BCM10 MOSI
21 BCM9 MISO
23 BCM11 SCLK
24 BCM8 CE0 (/SS)

Is correct ??

If is more easy, i use SPI of the RPi2 like MASTER and SPI of microprocessore like SLAVE
There is software and hardware example for realise an SPI communications?? with RPi2 ??

Thank you

User avatar
mikronauts
Posts: 2705
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: SPI Interface and program with Raspberry Pi 2

Thu Aug 06, 2015 3:10 pm

The RPi SPI is only supported as a master at this time.

So use the microcontroller as slave, RPi as master.

I do this all the time with SPI I/O chips.
Archi wrote:Good evening, i hope use the SPI serial communication, from RPi 2 and a microprocessor.

In the 40 pin connector there is only one SPI, in the PIN:

19 BCM10 MOSI
21 BCM9 MISO
23 BCM11 SCLK
24 BCM8 CE0 (/SS)

Is correct ??

If is more easy, i use SPI of the RPi2 like MASTER and SPI of microprocessore like SLAVE
There is software and hardware example for realise an SPI communications?? with RPi2 ??

Thank you
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

ghp
Posts: 1352
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: SPI Interface and program with Raspberry Pi 2

Thu Aug 06, 2015 3:42 pm

Hello,
I have done some experiments with SPI master -> slave from raspberry -> atmel328. Generally it is not a problem, but timing is critical. It is crucial to read in data fast enough on controller side, and to send data out only as fast as the slave can process them.

If you are a beginner in programming, it is easier to use serial connection. Serial is also easier to test, you can use minicom to simulate the pi side. If SPI not working, you need logic analyzers to find out what is going on.

For my setup, I needed to setup SPI to program the microcontroller from raspberry, so it was connected and I used it for communication too.
An example is to use the ADC from atmel328 with raspberry (it is not a pi2, but makes no difference), see http://heppg.de/ikg/wordpress/?p=209
In the download of the firmware, there is also python test code.
Regards,
Gerhard

User avatar
DougieLawson
Posts: 35373
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: SPI Interface and program with Raspberry Pi 2

Thu Aug 06, 2015 6:41 pm

There's two chip selects on the first 26 pins (for /dev/spidev0.0 & /dev/spidev0.1) and a second SPI interface on the full 40 pin header (A+/B+/2B).

http://pi.gadgetoid.com/pinout/spi
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Archi
Posts: 2
Joined: Wed Mar 18, 2015 7:43 am

Re: SPI Interface and program with Raspberry Pi 2

Wed Aug 12, 2015 7:53 am

Thank you at all

krishnaiah.vv
Posts: 19
Joined: Wed Jun 24, 2015 7:34 am

Re: SPI Interface and program with Raspberry Pi 2

Tue Aug 18, 2015 11:20 am

ghp wrote:Hello,
I have done some experiments with SPI master -> slave from raspberry -> atmel328. Generally it is not a problem, but timing is critical. It is crucial to read in data fast enough on controller side, and to send data out only as fast as the slave can process them.

If you are a beginner in programming, it is easier to use serial connection. Serial is also easier to test, you can use minicom to simulate the pi side. If SPI not working, you need logic analyzers to find out what is going on.

For my setup, I needed to setup SPI to program the microcontroller from raspberry, so it was connected and I used it for communication too.
An example is to use the ADC from atmel328 with raspberry (it is not a pi2, but makes no difference), see http://heppg.de/ikg/wordpress/?p=209
In the download of the firmware, there is also python test code.
Regards,
Gerhard
Did you make Pi as SPI slave and got it running? I just started now with SPI slave driver implementation.

ghp
Posts: 1352
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: SPI Interface and program with Raspberry Pi 2

Tue Aug 18, 2015 3:06 pm

SPI master -> slave from raspberry -> atmel328
Hello, possibly not very precise stated: I used SPI on raspberry as master, on atmel 328 as slave.
If you need communication where the atmel is initiating communication, then use serial line for this.
Regards,
Gerhard

There are ways to have raspberry as a master AND the slave is initiating communication when the slave uses a GPIO pin to signal 'data available'. Example is the 23S17 which has an 'interrupt pin'.

Return to “Interfacing (DSI, CSI, I2C, etc.)”