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

RPi 2 as SPI slave?

Tue Aug 04, 2015 9:53 am

Hello folks,

I am looking for some information if the "RPi 2" can be configured as SPI slave? The documentation(P.160) says that it can be configured and some forums discuss that its not possible to make SPI as slave in RPi.

Can someone kindly clarify this point? Pls note that, I am using "RPi 2"(40 pin header). Also, please if anyone has, post the links to example codes for SPI slave.

Thank you for the help in advance.
Krish

User avatar
joan
Posts: 14021
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: RPi 2 as SPI slave?

Tue Aug 04, 2015 10:42 am

The Pi may be configured as a SPI slave.

If you search the forum you will probably find some details (it was certainly posted about in 2015 so no need to look earlier than that).

It will work if the Pi's job is to always return a single value (say the latest reading). I don't see that it will work if you need to interpret the incoming SPI command. In my opinion the system will not be able to respond fast enough to interpret and then execute the command.

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

Re: RPi 2 as SPI slave?

Tue Aug 04, 2015 11:20 am

Hi Joan,

Thanks for your reply. I've searched the forum.. but there wasn't clear conclusion or some example code available. I would be happy when you could redirect me to the related posts in the forum.

Regd the need to configure as SPI slave, I just need to receive a block of data from Master Pi at higher speeds. So want to use other as SPI slave.

Thanks, Krish

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

Re: RPi 2 as SPI slave?

Thu Aug 13, 2015 1:34 pm

Hello Joan,

I am using the RPi Model B Revision 2 with BCM2836 chip. I've put my efforts in finding the datasheet for BCM2836, but couldn't find it.

What I would like to know in particular is whether GPIO19 to GPIO21 pins are now available on BCM2836 or not. I didn't find any differences regarding the pin layout between BCM2835 and 2836.

Also, I observed in BCM2835 Peripheral documentation(P.102) (https://www.raspberrypi.org/wp-content/ ... herals.pdf) that, GPIO19-GPIO21 can be configured as I2C/SPI slave.
But, there is no pin outs available for GPIO19 and 20 (http://elinux.org/RPi_BCM2835_GPIOs#GPIO20).

Could you please guide me / clarify if RPi can act as SPI slave at hardware level ? Is there an alternative approach other than bit banging.

Note: Btw, the short description about the project goal is to simulate the Micro Controllers from PC. For this, Pi receives a TCP/IP packet from PC and the extracted data has to be sent to the MCs over SPI/CAN/UART. Also, Pi receives back the data packets from MCs and to be transferred over to PC. Finally, in our student project, we want to use Pi as COM-Gateway.

Thank you very much in advance.
Krish

User avatar
joan
Posts: 14021
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: RPi 2 as SPI slave?

Thu Aug 13, 2015 1:53 pm

The BCM2835 peripheral documentation is correct for the Pi2.

Gpios 0-27 are available on the Pis with the 40 pin expansion header.

Code: Select all

           pin  pin
3V3         1    2      5V
2 (SDA)     3    4      5V
3 (SCL)     5    6      0V
4           7    8      14 (TXD)
0V          9   10      15 (RXD)
17 (ce1)   11   12      18 (ce0)
27         13   14      0V
22         15   16      23
3V3        17   18      24
10 (MOSI)  19   20      0V
9 (MISO)   21   22      25
11 (SCLK)  23   24      8 (CE0)
0V         25   26      7 (CE1)
           .......
0 (ID_SD)  27   28      1 (ID_SC)
5          29   30      0V
6          31   32      12
13         33   34      0V
19 (miso)  35   36      16 (ce2)
26         37   38      20 (mosi)
0V         39   40      21 (sclk)
Page 160 of the peripherals documents shows the detail.

You can't bit bang a SPI slave from userland unless you use a ridiculous bits per seconds of the order of say 10bps.

I suspect this task is too much for you to undertake. I admit I do not fully understand what you are trying to do. But if I understand correctly no one has posted software capable of doing what you want.

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

Re: RPi 2 as SPI slave?

Thu Aug 13, 2015 2:34 pm

Hello Joan,

I see this info in P.160 and i am clear in configuring the registers. But what i wonder is the about the schematics(2835) https://www.raspberrypi.org/wp-content/ ... .2_027.pdf. Its mentioned that there is not pin out available for GPIO 18 and 19.

May i know your source for confirming that these pins are taken out? Could you please share the same?

When there is confirmation source(schematics) that these pins are available, I will be highly motivated to proceed with writing the SPI slave driver and share the same with our Pi users.

Thanks, Krish

User avatar
rpdom
Posts: 14483
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: RPi 2 as SPI slave?

Thu Aug 13, 2015 3:42 pm

You won't find those pins on the schematics for the original Pi.

You need a model with the 40 pin header, like the B+ (partial) schematics

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