5

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:~ $
SmileDeveloper
  • 153
  • 1
  • 1
  • 5
  • Are you using Raspbian? What does uname -a report? What does cat /etc/os-release report. Edit the answers into your question. – joan Oct 04 '17 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 04 '17 at 20:12
  • OK I go try it. – SmileDeveloper Oct 05 '17 at 07: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 – SmileDeveloper Oct 05 '17 at 09:42
  • if i go try with bcm2835 to connect to my rfid reader the lcd screen turns off. – SmileDeveloper Oct 05 '17 at 09:44
  • You have not set if disabling the LCD allows the SPI devices to be seen at /dev/spi*. – joan Oct 05 '17 at 15:51

3 Answers3

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.

steviethecat
  • 261
  • 1
  • 13
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
BHP
  • 101
  • 3