4

I have installed a LCD screen that use my SPI0 bus and I2C but i want to connect my RFID reader to the same raspberry. My lcd screen can you see here: https://www.adafruit.com/product/1601

SPI1 will not be enabled with SPI0, i have searched for Enable SPI1 for raspberry Or Raspberry SPI1... But must results is links to enable SPI0 or SPI1 for python or SPI0 for c++

I want to use C++ as programming language. (you may send me C libarys but not Python)

This is the content of the raspberry file /boot/config.txt

https://pastebin.com/GrvAGzwx

Please tell me step step-by-step how you install SPI1 with SPI0 with C++

Can anybody help me please? Thank you. If you have the same problem please vote me. If you fix how i can enable the SPI and wich libary support SPI1 on C++ or C then you figured out my problem.

Added: Raspbian information:

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.9.52-v7+ #1038 SMP Fri Sep 29 16:26:52 BST 2017 armv7l GNU/Linux
pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~ $
6
  • Are you using Raspbian? What does uname -a report? What does cat /etc/os-release report. Edit the answers into your question.
    – joan
    Oct 4, 2017 at 17:51
  • 1
    All you need to do is have the line dtparam=spi=on in /boot/config.txt. I suspect the set-up for your LCD screen is claiming both SPI channels by mistake. You could test by removing whatever you are using to set-up the LCD screen and seeing if the SPI devices then appear.
    – joan
    Oct 4, 2017 at 20:12
  • OK I go try it. Oct 5, 2017 at 7:50
  • Okay, But i want that the LCD screen and RFID reader is working. So i want to use SPI1. Not only LCD screen or RFID reader Oct 5, 2017 at 9:42
  • if i go try with bcm2835 to connect to my rfid reader the lcd screen turns off. Oct 5, 2017 at 9:44

3 Answers 3

5

In order to use the spi1 port of the Raspberry Pi, you need to set the dtoverlay=spi1-1cs in /boot/config.txt. By default this will use the pins (https://pinout.xyz/pinout/spi):

  • MOSI - pin 38
  • MISO - pin 35
  • CE0 - pin 12
  • CLK - pin 40

You can change the CE0 pin (e.g. to pin 23) by adding ,cs0_pin=23 to the overlay. See /boot/overlays/README for more info.

1
  • It seems that cs0_pin can be any unused GPIO pin. It expects BCM numbers only. source Jan 22, 2019 at 2:43
0

Thank you all for the tips.

In my case, just add this dtoverlay=spi1-3cs to /boot/config.txt and reboot

I changed too in the MFRC522 library the following parameter: /dev/spidev0.0 to /dev/spidev1.0

In the pins were like this:

  • SDA/CE2: 36
  • MISO: 35
  • MOSI: 38
  • SCKL: 40
  • RESET: 13
0

In case anyone had the same problem, I had the same situation: using 3.5" LCD and MFRC522 at the same time. LCD driver is this and MFRC522 driver is this.

I added this line at the end of config.txt and it worked!

It seems LCD driver claims GPIO7 & GPIO8 pins.

dtoverlay=spi1-3cs,cs0_pin=05,cs1_pin=06,cs2_pin=16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.