I followed the instructions given in the blog and everything got executed without any errors. But in the end
https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
Ran this script:
wget https://raw.githubusercontent.com/raspberrypi/linux/rpi-3.10.y/Documentation/spi/spidev_test.c
gcc -o spidev_test spidev_test.c
./spidev_test -D /dev/spidev0.0
Expected output:
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D
Output which I got:
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00
I did connect MOSI and MISO. Also lsmod does show spibcm2708 drivers being enabled.
I tested the same tutorial on 2 Raspberry Pi, but same result. Where am I going wrong? What am I missing?
EDIT:
Error fixed. Thanks to @dastaan for spotting. I was using a 26 pin reference and hence was doing a wrong connection. It's working fine for me now.
/etc/modprobe.d/raspi-blacklist.conf
? If yes, comment it out by putting#
in front of it. Can you see spidev under /dev ? Run `ls -l /dev/spidev
. It should list outspidev-0.0
andspidev-0.1
. For more info read : learn.adafruit.com/downloads/pdf/… |configuring SPI
section. Hope it helps.