-2

I do not know device tree well and good. I have enabled spi through sudo raspi-config and then checked /boot/config.txt which includes dtparam=spi=on.

Then I checked lsmod | grep spi. It shows

spi_bcm2835            7596   0
spidev                 7373   0

Also checked sudo nano /etc/modprobe.d/raspi-blacklist.conf which is blank.

I have read a blog which suggested that spi-dev must include in /etc/modules to load spi. I got i2c-dev rather than that. I read How to make raspbian load the i2c-dev module on boot up also. I noticed some where that suggested not to load both of spi and i2c at the same time. That's why I have commented i2c-dev at /etc/modules and added spi-dev. Then there is an error like that says unable to load module spi-dev.

Question:

From spi-dev and spidev which one should I added to /etc/modules?

Somebody please help me if you got any useful tutorial about spi for beginners.

Notice:

For more about the problem please a look at How to check whether SPI working or not?

Output:

spi mode: 0
bits per word: 8
max speed: 80000 Hz (80 KHz)

00 00 00 00 00 00 
00 00 00 00 00 0C 
00 0C 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00

The above output is generated for ./spidev_test -D /dev/spidev0.0 -s 80000. Is this working (look there are two 0C & sometimes all are 00)?

testuser
  • 85
  • 1
  • 2
  • 10

1 Answers1

2

To enable SPI just add the line dtparam=spi=on to /boot/config.txt. Nothing else is required.

You should see the SPI devices in /dev after boot (try ls /dev/spi*).

I2C needs a similar device tree entry in /boot/config.txt AND the line i2c-dev in /etc/modules.

There is no problem in loading and using I2C and SPI at the same time. They use different GPIO.

joan
  • 71,852
  • 5
  • 76
  • 108