jfenwick
Posts: 5
Joined: Wed May 23, 2012 7:08 pm

Flaky SPI

Fri Feb 08, 2013 12:10 am

I was following this guide to get SPI working:
http://www.brianhensley.net/2012/07/get ... 0436921000

Basically it uses rpi-update to update to the latest kernel.
Then I took the SPI driver off the modprobe blacklist.
The SPI devices started showing up in /dev.
After I rebooted, I ran the spidev_test.c and it gave me all 0s.
Then I rebooted again and it seemed to work.
Then suddenly it wasn't working and it's spitting out all 0s.
What could I be doing wrong?

jfenwick
Posts: 5
Joined: Wed May 23, 2012 7:08 pm

Re: Flaky SPI

Fri Feb 08, 2013 12:34 am

Found this tutorial:
http://www.cmdrkeen.net/2012/11/06/play ... on-the-pi/

Tried tying together MISO and MOSI and then I get *some* sort of data back, but not what I was expecting based on the original tutorial I was following.

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Flaky SPI

Fri Feb 08, 2013 3:00 pm

Works fine for me.

* Put a wire between MOSI and MISO (loopback).
* Compile and run test:

Code: Select all

cp /usr/src/linux/Documentation/spi/spidev_test.c /tmp
cd /tmp
gcc -o spidev_test spidev_test.c

./spidev_test --device /dev/spidev0.0 --speed=32000000
spi mode: 0
bits per word: 8
max speed: 32000000 Hz (32000 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
32MHz seem to be max speed.
See this post for SPI speeds: http://www.raspberrypi.org/phpBB3/viewt ... 94#p224394

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